diff --git a/packages/client-android/App.tsx b/packages/client-android/App.tsx index 6065f75..bd41b79 100644 --- a/packages/client-android/App.tsx +++ b/packages/client-android/App.tsx @@ -130,25 +130,36 @@ export default function App() { {/* ── Terminal Tab ── */} {tab === 'terminal' && ( - - - - Execute remote commands via Gateway MCP.{'\n'}Type a shell command and press Execute.{'\n'} - - - - - - Run - - - + (() => { + const [cmd, setCmd] = useState(''); + const [out, setOut] = useState('Execute remote commands via Gateway MCP.\nType a shell command and press Execute.\n'); + const [running, setRunning] = useState(false); + const runCmd = async () => { + if (!cmd.trim() || running) return; + const c = cmd.trim(); setCmd(''); setRunning(true); + setOut(o => o + `$ ${c}\n`); + try { + const r = await fetch(`${gatewayUrl}/tools/exec`, { method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({command:c}), signal:AbortSignal.timeout(30000) }); + if (!r.ok) throw new Error(`HTTP ${r.status}`); + const d = await r.json() as any; + setOut(o => o + (d.stdout||d.stderr||JSON.stringify(d)) + '\n'); + } catch(e:any) { setOut(o => o + `Error: ${e.message}\n`); } + finally { setRunning(false); } + }; + return ( + + + {out} + + + + + {running ? '...' : 'Run'} + + + + ); + })() )} {/* ── Settings Tab ── */}