import { useState, useEffect } from 'react'; import { invoke } from '@tauri-apps/api/core'; import { X, Server, WifiOff } from 'lucide-react'; import '../styles/PortManager.css'; interface PortManagerProps { onClose: () => void; } export function PortManager({ onClose }: PortManagerProps) { const [isServerRunning, setIsServerRunning] = useState(false); const [serverPort] = useState(8080); const [isChecking, setIsChecking] = useState(false); const [isStopping, setIsStopping] = useState(false); useEffect(() => { checkServerStatus(); }, []); const checkServerStatus = async () => { setIsChecking(true); try { const status = await invoke('get_profiler_status'); setIsServerRunning(status); } catch (error) { console.error('[PortManager] Failed to check server status:', error); setIsServerRunning(false); } finally { setIsChecking(false); } }; const handleStopServer = async () => { setIsStopping(true); try { const result = await invoke('stop_profiler_server'); console.log('[PortManager]', result); setIsServerRunning(false); } catch (error) { console.error('[PortManager] Failed to stop server:', error); } finally { setIsStopping(false); } }; return (
e.stopPropagation()}>

Port Manager

Profiler Server

Status: {isChecking ? 'Checking...' : isServerRunning ? 'Running' : 'Stopped'}
{isServerRunning && (
Port: {serverPort}
)}
{isServerRunning && (
)} {!isServerRunning && (

No server is currently running.

Open Profiler window to start the server.

)}

Tips

  • Use this when the Profiler server port is stuck and cannot be restarted
  • The server will automatically stop when the Profiler window is closed
  • Default port: 8080
); }