import { useState, useEffect } from "react"; import { startWebTerminal, stopWebTerminal, getWebTerminalStatus, regenerateWebTerminalToken } from "../../lib/tauri-commands"; import type { WebTerminalInfo } from "../../lib/types"; import Tooltip from "../ui/Tooltip"; export default function WebTerminalSettings() { const [info, setInfo] = useState(null); const [loading, setLoading] = useState(false); const [copied, setCopied] = useState(false); useEffect(() => { getWebTerminalStatus().then(setInfo).catch(console.error); }, []); const handleToggle = async () => { setLoading(true); try { if (info?.running) { await stopWebTerminal(); const updated = await getWebTerminalStatus(); setInfo(updated); } else { const updated = await startWebTerminal(); setInfo(updated); } } catch (e) { console.error("Web terminal toggle failed:", e); } finally { setLoading(false); } }; const handleRegenerate = async () => { try { const updated = await regenerateWebTerminalToken(); setInfo(updated); } catch (e) { console.error("Token regeneration failed:", e); } }; const handleCopyUrl = async () => { if (info?.url) { await navigator.clipboard.writeText(info.url); setCopied(true); setTimeout(() => setCopied(false), 2000); } }; const handleCopyToken = async () => { if (info?.access_token) { await navigator.clipboard.writeText(info.access_token); setCopied(true); setTimeout(() => setCopied(false), 2000); } }; return (

Serves a browser-based terminal UI on your local network for remote access to running projects.

{/* Toggle */}
{info?.running ? `Running on port ${info.port}` : "Stopped"}
{/* URL + Copy */} {info?.running && info.url && (
{info.url}
)} {/* Token */} {info && (
Token: {info.access_token ? `${info.access_token.slice(0, 12)}...` : "None"}
)}
); }