Overview
TUIOS daemon mode enables persistent sessions that survive terminal disconnection. The daemon manages PTYs (pseudo-terminals) and stores session state, while clients attach/detach to view and interact with sessions.Architecture
- Sessions persist when you disconnect
- Multiple clients can attach to the same session
- Remote control via CLI commands
- Session state survives crashes
The daemon starts automatically when you create or attach to a session. You rarely need to manage it manually.
Session Lifecycle
Creating a New Session
Create a named session:Attaching to an Existing Session
Attach to a named session:new-session -A):
Detaching from a Session
While inside TUIOS, press the detach key:Listing Sessions
View all active sessions:tuios list-sessions
Killing a Session
Terminate a session and all its windows:Daemon Management
Starting the Daemon
The daemon starts automatically, but you can start it manually:This command is hidden because users rarely need it. Sessions automatically start the daemon.
Running in Foreground (Debugging)
Run the daemon in the foreground with debug logging:off- No debug output (default)errors- Only error messagesbasic- Connection events and errorsmessages- All protocol messages except PTY I/Overbose- All messages including PTY I/Otrace- Full payload hex dumps
Stopping the Daemon
Shutdown the daemon (terminates all sessions):- Disconnects all clients
- Closes all PTYs
- Removes the Unix socket
- Exits the daemon process
Viewing Daemon Logs
View recent daemon activity:State Persistence
What Gets Persisted
The daemon stores: Window State:- Window position, size, z-order
- Workspace assignment
- Custom window names
- Minimized state
- Terminal content (scrollback + screen)
- Current workspace (1-9)
- Focused window per workspace
- Tiling mode enabled/disabled
- Master ratio for tiling
- BSP tree structure
- Running shell processes
- Terminal screen buffer
- Scrollback history (10,000 lines)
- Cursor position
- Terminal modes (mouse tracking, etc.)
Terminal content is fully preserved across disconnects. When you reattach, you’ll see exactly what was on screen, including all colors and formatting.
Reconnection Flow
When you attach to an existing session:- Daemon sends session state - Window positions, workspace, tiling mode
- Client restores windows - Creates window objects from state
- Daemon sends terminal states - Screen content, scrollback, cursor position
- Client syncs PTY handlers - Connects to daemon’s PTY output streams
- Client redraws UI - Renders everything exactly as it was
Multi-Client Sessions
Multiple clients can attach to the same session simultaneously.Behavior
- Shared state - All clients see the same windows, workspace, focus
- Synchronized input - Changes from one client appear on all clients
- Size adaptation - Session size = minimum of all client sizes
- Independent detach - Clients can attach/detach independently
Size Handling
When multiple clients connect:Example Workflow
Terminal 1:Socket and PID Files
Socket Location
Linux/macOS:PID File
Linux/macOS:Troubleshooting
Daemon Won’t Start
Check for stale socket:Can’t Attach to Session
List sessions:Session State Corrupted
Kill and recreate:Advanced Usage
Scripting with Sessions
Create and populate a session via CLI:Integration with tmux
TUIOS complements tmux:SSH Server Integration
Run TUIOS daemon sessions over SSH:Comparison: Daemon Mode vs. Local Mode
| Feature | Daemon Mode | Local Mode |
|---|---|---|
| Persistence | ✅ Sessions survive disconnect | ❌ Exits when closed |
| Multi-client | ✅ Multiple attachments | ❌ Single instance |
| Remote control | ✅ CLI commands | ❌ Not available |
| State recovery | ✅ Full state + terminal content | ❌ Lost on exit |
| Complexity | Daemon + socket | Single process |
| Use case | Persistent workflows | Quick sessions |
See Also
Remote Control
Send commands to running sessions
SSH Server
Run TUIOS over SSH
Configuration
Daemon and session settings