diff --git a/packages/client-android/App.tsx b/packages/client-android/App.tsx
index bd41b79..3f14445 100644
--- a/packages/client-android/App.tsx
+++ b/packages/client-android/App.tsx
@@ -28,6 +28,23 @@ export default function App() {
// Connection state
const [connStatus, setConnStatus] = useState<'disconnected' | 'connecting' | 'connected' | 'error'>('disconnected');
+ // Terminal state
+ const [termCmd, setTermCmd] = useState('');
+ const [termOut, setTermOut] = useState('Execute remote commands via Gateway MCP.\nType a shell command and press Execute.\n');
+ const [termRunning, setTermRunning] = useState(false);
+ const runTermCmd = async () => {
+ if (!termCmd.trim() || termRunning) return;
+ const c = termCmd.trim(); setTermCmd(''); setTermRunning(true);
+ setTermOut(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;
+ setTermOut(o => o + (d.stdout||d.stderr||JSON.stringify(d)) + '\n');
+ } catch(e:any) { setTermOut(o => o + `Error: ${e.message}\n`); }
+ finally { setTermRunning(false); }
+ };
+
/** Send chat message to Gateway */
const sendMessage = async () => {
const text = input.trim();
@@ -130,36 +147,17 @@ export default function App() {
{/* ── Terminal Tab ── */}
{tab === 'terminal' && (
- (() => {
- 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'}
-
-
-
- );
- })()
+
+
+ {termOut}
+
+
+
+
+ {termRunning ? '...' : 'Run'}
+
+
+
)}
{/* ── Settings Tab ── */}