TUIOSTUIOS

Web Terminal

Access TUIOS from any browser with WebGL rendering (separate tuios-web binary)

Access TUIOS from any modern web browser with hardware-accelerated rendering and low-latency connections.

Powered by Sip

The web terminal is powered by sip, a standalone library for serving Bubble Tea apps through the browser. You can use sip to serve your own Bubble Tea applications on the web!

Separate Binary

The web terminal functionality is provided as a separate tuios-web binary for security isolation. This prevents the web server from being used as a potential backdoor in the main TUIOS binary.

Installation

brew install tuios-web
yay -S tuios-web-bin
# or
paru -S tuios-web-bin
go install github.com/Gaurav-Gosain/tuios/cmd/tuios-web@latest

Quick Start

Start the web server

tuios-web

This starts:

  • HTTP server on http://localhost:7681 (static files, WebSocket)
  • WebTransport server on https://127.0.0.1:7682 (QUIC/UDP)

Open in browser

open http://localhost:7681

The browser will automatically connect using the best available transport (WebTransport if supported, WebSocket otherwise).

Features

  • WebGL Rendering - GPU-accelerated terminal at 60fps
  • Dual Protocols - WebTransport (QUIC) with WebSocket fallback
  • Bundled Fonts - JetBrains Mono Nerd Font included
  • Settings Panel - Configure transport, renderer, font size
  • Mouse Support - Full interaction with cell-based optimization
  • Auto-Reconnect - Automatic reconnection with backoff
  • Read-Only Mode - View-only sessions for demos

Command Reference

tuios-web [flags]

Flags

FlagDefaultDescription
--port7681HTTP server port
--hostlocalhostServer bind address
--read-onlyfalseDisable client input
--max-connections0Max concurrent sessions (0=unlimited)

TUIOS Flags

All TUIOS flags are forwarded to the spawned instance:

# With theme
tuios-web --theme dracula

# With show-keys overlay
tuios-web --show-keys

# Disable animations for instant transitions
tuios-web --no-animations

# Multiple flags
tuios-web --theme nord --ascii-only --debug

Client Settings

Click the ⚙ button in the top-right corner to access settings:

Transport

OptionDescription
AutoPrefer WebTransport, fallback to WebSocket
WebTransportForce QUIC (lower latency)
WebSocketForce WebSocket (wider compatibility)

Renderer

OptionDescription
AutoPrefer WebGL, fallback to Canvas/DOM
WebGLGPU-accelerated (best performance)
Canvas2D canvas (good compatibility)
DOMStandard DOM (most compatible)

Font Size

Adjustable from 10px to 24px. Settings persist in localStorage.

Architecture

Loading diagram...

Message Protocol

TypeCodeDirectionDescription
Input0C→SKeyboard/mouse input
Output1S→CTerminal output data
Resize2C→STerminal size change
Ping3C→SKeep-alive ping
Pong4S→CKeep-alive response
Title5S→CWindow title update
Options6S→CSession configuration
Close7S→CSession ended

Reverse Proxy Setup

For production deployments, put TUIOS behind a reverse proxy with proper TLS.

Important

WebTransport requires HTTP/3 (QUIC) support. Most reverse proxies only support WebSocket, so WebTransport connections will fall back to WebSocket when proxied.

Cloudflare Tunnel

Cloudflare Tunnels provide secure access without opening ports.

Install cloudflared

# macOS
brew install cloudflare/cloudflare/cloudflared

# Linux
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o cloudflared
chmod +x cloudflared
sudo mv cloudflared /usr/local/bin/

Authenticate

cloudflared tunnel login

Create tunnel

cloudflared tunnel create tuios

Configure tunnel

Create ~/.cloudflared/config.yml:

tunnel: <your-tunnel-id>
credentials-file: /path/to/credentials.json

ingress:
  - hostname: tuios.yourdomain.com
    service: http://localhost:7681
  - service: http_status:404

Start TUIOS and tunnel

# Terminal 1: Start TUIOS web server
tuios-web --host 127.0.0.1

# Terminal 2: Start tunnel
cloudflared tunnel run tuios

Add DNS record

cloudflared tunnel route dns tuios tuios.yourdomain.com

Access at https://tuios.yourdomain.com

Nginx

server {
    listen 80;
    server_name tuios.example.com;

    location / {
        proxy_pass http://127.0.0.1:7681;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_read_timeout 86400;
    }
}
server {
    listen 443 ssl http2;
    server_name tuios.example.com;

    ssl_certificate /etc/letsencrypt/live/tuios.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/tuios.example.com/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:7681;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 86400;
        proxy_send_timeout 86400;
    }
}

server {
    listen 80;
    server_name tuios.example.com;
    return 301 https://$server_name$request_uri;
}

Caddy

Caddy automatically handles TLS certificates:

tuios.example.com {
    reverse_proxy localhost:7681
}

Traefik

# docker-compose.yml
services:
  tuios:
    image: ghcr.io/gaurav-gosain/tuios:latest
    command: web --host 0.0.0.0
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.tuios.rule=Host(`tuios.example.com`)"
      - "traefik.http.routers.tuios.entrypoints=websecure"
      - "traefik.http.routers.tuios.tls.certresolver=letsencrypt"
      - "traefik.http.services.tuios.loadbalancer.server.port=7681"

Security Considerations

Development Mode

By default, TUIOS generates a self-signed certificate for WebTransport:

  • Valid for 10 days (Chrome requirement for serverCertificateHashes)
  • Certificate hash provided via /cert-hash endpoint
  • No browser warning for WebTransport connections

Production Recommendations

Security Tips

  1. Always use a reverse proxy with proper TLS for production
  2. Bind to localhost: tuios-web --host 127.0.0.1
  3. Limit connections: tuios-web --max-connections 10
  4. Use read-only for demos: tuios-web --read-only
  5. Add authentication at the reverse proxy level

Basic Auth with Nginx

location / {
    auth_basic "TUIOS";
    auth_basic_user_file /etc/nginx/.htpasswd;
    
    proxy_pass http://127.0.0.1:7681;
    # ... rest of proxy config
}

Create password file:

htpasswd -c /etc/nginx/.htpasswd username

Performance

Server Optimizations

  • Buffer Pools - Reusable buffers reduce GC pressure
  • Atomic Counters - Lock-free connection counting
  • Direct Streaming - No intermediate buffering
  • Structured Logging - charmbracelet/log with configurable levels

Client Optimizations

  • requestAnimationFrame Batching - Writes batched per frame
  • Mouse Deduplication - Only sends on cell position change
  • Pre-allocated Buffers - Reusable send/receive buffers
  • Cached DOM Elements - No repeated queries

Typical Metrics

MetricValue
Latency (local)<5ms
Latency (LAN)<20ms
Mouse events filtered80-95%
Memory (per session)~10MB

Troubleshooting

WebTransport Not Connecting

  1. Check browser support - Chrome 97+, Edge 97+
  2. Verify UDP port - Port 7682 must be accessible
  3. Check console - Look for certificate hash errors
  4. Force WebSocket - Use settings panel to switch

Blank Terminal

  1. Check console - Look for JavaScript errors
  2. Verify fonts - Check if fonts loaded
  3. Try different renderer - Switch in settings
  4. Check server logs - Verify TUIOS process started

High Latency

  1. Check network - Run speed test
  2. Prefer WebTransport - Lower latency than WebSocket
  3. Use WebGL - Hardware acceleration
  4. Check server CPU - May be overloaded

Session Not Closing

When TUIOS quits (pressing q), the web session should close automatically. If not:

  1. Check browser console for errors
  2. Verify server logs show session cleanup
  3. Refresh browser to start new session

Debug Mode

tuios-web --debug

Server logs include:

  • Connection attempts
  • Session lifecycle
  • Bytes sent/received
  • Terminal resize events
  • Error details

Examples

Public Demo Server

# Read-only with connection limit
tuios-web \
  --host 0.0.0.0 \
  --port 7681 \
  --read-only \
  --max-connections 50 \
  --theme dracula

Development with Hot Reload

# With debug logging
tuios-web --debug --show-keys

Docker Deployment

docker run -it --rm \
  -p 7681:7681 \
  -p 7682:7682/udp \
  ghcr.io/gaurav-gosain/tuios:latest \
  web --host 0.0.0.0

Systemd Service

# /etc/systemd/system/tuios-web.service
[Unit]
Description=TUIOS Web Terminal
After=network.target

[Service]
Type=simple
User=tuios
ExecStart=/usr/local/bin/tuios-web --host 127.0.0.1 --port 7681
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
sudo systemctl enable tuios-web
sudo systemctl start tuios-web

On this page