Documentation Index
Fetch the complete documentation index at: https://mintlify.com/jaypopat/cf_ai_duet/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Duet’s shared terminal provides a fully synchronized shell environment where all participants see exactly the same output in real time. Every keystroke, command, and output is instantly visible to everyone in the session.How it works
The terminal is built on three key technologies:PTY
Pseudoterminal provides a real shell process with full terminal capabilities
VT10x
Terminal emulator handles ANSI escape sequences, colors, and cursor positioning
Pub/Sub
Subscriber pattern broadcasts updates to all connected clients
Terminal initialization
When a room is created, Duet starts a shell in an isolated workspace:Each room gets its own shell process running in
/app/workspaces/{workspace-name}. This provides complete isolation between sessions.Real-time synchronization
Duet uses a subscriber pattern to keep all participants in sync:Rendering optimization
Duet minimizes CPU usage with smart caching:- Performance
- Color support
- Caching: Only re-renders when PTY output changes (dirty flag)
- Run-length encoding: ANSI color codes only emitted when colors change
- Efficient broadcast: Non-blocking channel sends to all subscribers
Window resizing
When your terminal window changes size, Duet automatically adjusts:Typing indicators
Duet shows when other participants are actively typing:Cursor rendering
The cursor position is synchronized across all clients using reverse video:Terminal lifecycle
Supported features
Full shell interaction
Full shell interaction
- Execute any shell command
- Run interactive programs (vim, htop, etc.)
- Tab completion
- Command history (arrow keys)
- Job control (Ctrl+C, Ctrl+Z)
ANSI escape sequences
ANSI escape sequences
- Cursor movement (\x1b[A, \x1b[B, etc.)
- Text styling (bold, italic, underline)
- 256-color palette
- Clear screen / line
- Save/restore cursor position
Special keys
Special keys
All keyboard input is properly mapped:
- Arrow keys →
\x1b[Athrough\x1b[D - Home/End →
\x1b[H/\x1b[F - Backspace → ASCII 127
- Delete →
\x1b[3~ - Tab →
\t - Enter →
\r
Workspace isolation
Each room operates in its own directory:Workspaces are completely isolated. You can create files, install packages, and run processes without affecting other rooms. Everything is cleaned up when the session ends.
Limitations
Next steps
AI assistant
Get AI-powered help while coding in the shared terminal
Sandbox execution
Run isolated commands using Cloudflare Sandboxes