// ======================================== // CodexLens LSP Server Card // ======================================== // Displays LSP server status, stats, and start/stop/restart controls import { useIntl } from 'react-intl'; import { Server, Power, PowerOff, RotateCw, FolderOpen, Layers, Cpu, } from 'lucide-react'; import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/Card'; import { Badge } from '@/components/ui/Badge'; import { Button } from '@/components/ui/Button'; import { cn } from '@/lib/utils'; import { useCodexLensLspStatus, useCodexLensLspMutations } from '@/hooks'; import { useWorkflowStore, selectProjectPath } from '@/stores/workflowStore'; interface LspServerCardProps { disabled?: boolean; } export function LspServerCard({ disabled = false }: LspServerCardProps) { const { formatMessage } = useIntl(); const projectPath = useWorkflowStore(selectProjectPath); const { available, semanticAvailable, projectCount, modes, isLoading, } = useCodexLensLspStatus(); const { startLsp, stopLsp, restartLsp, isStarting, isStopping, isRestarting } = useCodexLensLspMutations(); const isMutating = isStarting || isStopping || isRestarting; const handleToggle = async () => { if (available) { await stopLsp(projectPath); } else { await startLsp(projectPath); } }; const handleRestart = async () => { await restartLsp(projectPath); }; return (
{formatMessage({ id: 'codexlens.lsp.title' })}
{available ? formatMessage({ id: 'codexlens.lsp.status.running' }) : formatMessage({ id: 'codexlens.lsp.status.stopped' }) }
{/* Stats Grid */}

{formatMessage({ id: 'codexlens.lsp.projects' })}

{available ? projectCount : '--'}

{formatMessage({ id: 'codexlens.lsp.semanticAvailable' })}

{semanticAvailable ? formatMessage({ id: 'codexlens.lsp.available' }) : formatMessage({ id: 'codexlens.lsp.unavailable' }) }

0 ? 'text-accent' : 'text-muted-foreground')} />

{formatMessage({ id: 'codexlens.lsp.modes' })}

{available ? modes.length : '--'}

{/* Action Buttons */}
{available && ( )}
); } export default LspServerCard;