HAPI provides remote terminal access to your coding sessions via xterm.js, allowing you to run commands on your development machine from your phone or any web browser.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tiann/hapi/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Full Terminal Emulator
xterm.js provides a complete terminal experience in the browser
Real-Time Communication
Commands and output stream via Socket.IO with minimal latency
Mobile-Friendly
Touch keyboard with special keys (Esc, Tab, Ctrl, arrows)
Session-Linked
Terminal automatically connects to your active session’s machine
Accessing the Terminal
From Web App
Route
The terminal is available at:Features
Full Terminal Emulation
Powered by xterm.js, the terminal supports:- 256 colors and true color
- Unicode characters
- Cursor positioning and control sequences
- Scrollback buffer for history
- Text selection and copy/paste
Touch Keyboard
On mobile, HAPI provides quick-access buttons for special keys:Esc
Escape key
Tab
Tab key for autocomplete
Ctrl
Control modifier (stays active)
Alt
Alt/Option modifier
- Arrow keys (↑ ↓ ← →)
- Home and End
- Page Up and Page Down
Paste Functionality
Two ways to paste text:- Automatic: Tap Paste button to use clipboard (if browser supports)
- Manual: If clipboard unavailable, a dialog appears for manual paste
iOS Safari has clipboard limitations. The manual paste dialog is a reliable fallback.
Real-Time Updates
Terminal output streams in real-time:- Instant feedback on commands
- Live tailing of logs
- Interactive programs (vim, nano, htop)
- Tab completion works as expected
Technical Architecture
Communication Flow
Components
-
Browser (xterm.js)
- Renders terminal in browser
- Captures keyboard input
- Displays output with ANSI colors
-
Hub (Socket.IO)
- Routes terminal events
- Manages terminal registry
- Handles connection state
-
CLI (PTY)
- Spawns shell process
- Reads/writes to pseudo-terminal
- Handles resize events
Socket.IO Events
Web → CLI
| Event | Description |
|---|---|
terminal:create | Request new terminal session |
terminal:write | Send input to terminal |
terminal:resize | Update terminal dimensions |
terminal:close | Close terminal session |
CLI → Web
| Event | Description |
|---|---|
terminal:ready | Terminal is ready for input |
terminal:output | Output from terminal |
terminal:exit | Terminal process exited |
terminal:error | Error occurred |
Use Cases
Quick Command Execution
Run simple commands without switching to terminal:Emergency Fixes
Fix issues while away from your desk:- Get notified about production issue
- Open terminal on phone
- SSH to production server
- Apply hotfix
- Restart service
File Management
Manage files when AI can’t:Interactive Programs
Run interactive CLI tools:Connection States
Terminal shows connection status:Connecting
Establishing Socket.IO connection
Connected
Ready for input (green indicator)
Offline
Disconnected or session inactive
Session Requirements
Terminal is only available when:- ✅ Session is active (agent running)
- ✅ Machine is online
- ✅ CLI is connected to hub
Keyboard Shortcuts
Desktop
All standard terminal shortcuts work:| Shortcut | Action |
|---|---|
Ctrl+C | Interrupt (SIGINT) |
Ctrl+D | EOF / Exit |
Ctrl+L | Clear screen |
Ctrl+R | Reverse search |
Ctrl+A | Move to start of line |
Ctrl+E | Move to end of line |
Ctrl+K | Kill to end of line |
Ctrl+U | Kill to start of line |
Mobile
Use the quick-access keyboard:- Ctrl button: Tap to enable, then tap any key for Ctrl+Key
- Alt button: Tap to enable, then tap any key for Alt+Key
- Arrow keys: Navigation without virtual keyboard
Best Practices
Session Management
Session Management
- Keep terminal tab open for continuous connection
- Close terminal when done to free resources
- One terminal per session (multiple tabs share same PTY)
Mobile Usage
Mobile Usage
- Use landscape mode for more screen space
- Rely on quick-access keys for special characters
- Use paste dialog for long commands
Security
Security
- Terminal has same permissions as CLI process
- No isolation — use caution with destructive commands
- Consider read-only mode for sensitive environments
Performance
Performance
- Avoid commands with massive output
- Use
head,tail, orgrepto limit output - Close terminal when not needed
Limitations
Troubleshooting
Terminal Not Connecting
Terminal Not Connecting
Check:
- Session is active (green indicator)
- CLI is connected to hub
- Socket.IO connection is established
- No firewall blocking WebSocket
Input Not Working
Input Not Working
Check:
- Terminal shows “Connected” status
- Click terminal area to focus
- Try quick-access keys on mobile
Garbled Output
Garbled Output
Cause: Terminal size mismatchSolution:
- Resize browser window
- Run
resetcommand - Close and reopen terminal
Process Exited Unexpectedly
Process Exited Unexpectedly
Displayed:Solution: Close and reopen terminal tab to spawn new shell
Paste Not Working (iOS)
Paste Not Working (iOS)
Cause: iOS Safari clipboard restrictionsSolution: Use the manual paste dialog that appears automatically
Security Considerations
Authentication
- Terminal inherits session authentication
- Requires valid JWT token
- No separate terminal password
Permissions
- Terminal runs as same user as CLI
- Has access to all files CLI can access
- No sandboxing or isolation
Network
- Uses WebSocket (secure if HTTPS)
- Data is not encrypted beyond TLS
- Consider VPN for sensitive environments
Related Features
Remote Control
Switch between local and remote modes
File Browser
Browse files and view diffs
Permissions
Control what agents can do