Rust Terminal Forge¶
Browser-based terminal emulator that marries a React front end with a Rust-powered execution core.
Signal¶
Project Signal
- Status: Experimental, actively prototyping
- Focus: Secure, sandboxed terminals in the browser
- Stack: React, TypeScript, Vite, Rust backend exposed via WebAssembly/websocket bridge
- Ideal For: Builders exploring hybrid Rust + frontend architectures
Quick Links¶
Onboarding Checklist¶
- Install dependencies for the React client (
pnpm install) and start it withpnpm dev. - Build/run the Rust backend (see
server/instructions) to expose websocket connections for the terminal stream. - Configure
.envvalues for allowed commands and API keys, then open the browser UI to connect to the local server.
Highlights¶
- Full terminal emulation rendered via React with caret, cursor, and theme support.
- Rust backend enforces command safelists while streaming output efficiently to the browser.
- Responsive layout keeps touch bars and keyboard shortcuts usable on tablets.
Code Snapshot¶
import { useEffect, useRef } from 'react';
import { useWebSocket } from '../hooks/useWebSocket';
export function Terminal() {
const containerRef = useRef<HTMLDivElement>(null);
const { send, messages } = useWebSocket('/ws/terminal');
return (
<div ref={containerRef} className="terminal-viewport">
{messages.map((msg, i) => (
<pre key={i}>{msg.data}</pre>
))}
<input
onKeyDown={(e) => {
if (e.key === 'Enter') send(e.currentTarget.value);
}}
placeholder="Type a command..."
/>
</div>
);
}
use axum::extract::ws::{Message, WebSocket};
use tokio::process::Command;
pub async fn handle_command(
socket: &mut WebSocket,
cmd: &str,
) -> anyhow::Result<()> {
let output = Command::new("sh")
.arg("-c")
.arg(cmd)
.output()
.await?;
let text = String::from_utf8_lossy(&output.stdout);
socket.send(Message::Text(text.into())).await?;
Ok(())
}
Core Scenarios¶
- Remote labs: Offer sandboxed terminals for demos or onboarding labs without exposing SSH.
- Hybrid stack experiments: Prototype Rust + TypeScript interop patterns for other projects.
- Security research: Test enforcement of allowed commands, rate limits, and session isolation.
Documentation Map¶
| Document | Description |
|---|---|
| Quick Start | Dev environment, scripts, and dual frontend/backend boot sequence |
| Terminal Details | Architecture notes covering websocket streaming and security controls |
| Known Issues | Track experimental limitations and open bugs |