import { useEffect, useRef, useState } from 'react'; import { Terminal, Info, Send, Loader2 } from 'lucide-react'; import { useCliStore } from '../../store/cli'; export default function CliDashboard() { const { history, isExecuting, execute, loadHistory, clearOutput, navigateHistory, } = useCliStore(); const [input, setInput] = useState(''); const outputRef = useRef(null); useEffect(() => { loadHistory(); }, [loadHistory]); // Auto-scroll to bottom when history changes useEffect(() => { if (outputRef.current) { outputRef.current.scrollTop = outputRef.current.scrollHeight; } }, [history]); const handleCommand = async () => { if (!input.trim() || isExecuting) return; const cmd = input.trim(); setInput(''); await execute(cmd); }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter') { handleCommand(); } else if (e.key === 'ArrowUp') { e.preventDefault(); const prev = navigateHistory('up'); if (prev !== null) setInput(prev); } else if (e.key === 'ArrowDown') { e.preventDefault(); const next = navigateHistory('down'); if (next !== null) setInput(next); } }; return (

CLI Mode

Terminal interface for power users

{/* Welcome message if no history */} {history.length === 0 && (

{'>'} Welcome to Synor CLI Mode

{'>'} Type "help" for available commands

{'>'}

)} {/* Command history */} {history.map((result, i) => (
{'>'} {result.command}
{result.output}
))} {/* Loading indicator */} {isExecuting && (
Executing...
)}
{'>'} setInput(e.target.value)} onKeyDown={handleKeyDown} placeholder="Enter command..." className="flex-1 bg-transparent text-white font-mono outline-none" autoFocus disabled={isExecuting} />
{/* Quick Commands */}

Quick Commands

{['help', 'balance', 'address', 'status', 'utxos', 'peers'].map((cmd) => ( ))}
{/* Command Reference */}

Command Reference

help
Show all available commands
balance
Show wallet balance
address
Show wallet addresses
send <addr> <amount>
Send SYN to address
utxos
List unspent outputs
history
Transaction history
status
Network status
peers
Connected peers
clear
Clear output

CLI mode provides a terminal interface for advanced users who prefer keyboard-driven interaction. Use ↑/↓ arrows to navigate command history.

); }