Complete guide for using tmux integration with oh-my-opencode-slim to watch agents work in real-time through automatic pane spawning.
Watch your agents work in real-time. When the Orchestrator launches sub-agents or initiates background tasks, new tmux panes automatically spawn showing each agent's live progress. No more waiting in the dark.
⚠️ Temporary workaround: Start OpenCode with
--portto enable tmux integration. The port must match theOPENCODE_PORTenvironment variable (default: 4096). This is required until the upstream issue is resolved. opencode#9099.
Edit ~/.config/opencode/oh-my-opencode-slim.json (or .jsonc):
{
"tmux": {
"enabled": true,
"layout": "main-vertical",
"main_pane_size": 60
}
}
# Start a new tmux session
tmux
# Start OpenCode with the default port (4096)
opencode --port 4096
That's it! Your agents will now spawn panes automatically.
Configure tmux behavior in ~/.config/opencode/oh-my-opencode-slim.json (or .jsonc):
{
"tmux": {
"enabled": true,
"layout": "main-vertical",
"main_pane_size": 60
}
}
| Setting | Type | Default | Description |
|---|---|---|---|
enabled |
boolean | false |
Enable/disable tmux pane spawning |
layout |
string | "main-vertical" |
Layout preset (see Layout Options) |
main_pane_size |
number | 60 |
Main pane size as percentage (20-80) |
Choose how panes are arranged:
| Layout | Description |
|---|---|
main-vertical |
Your session on the left (60%), agents stacked on the right |
main-horizontal |
Your session on top (60%), agents stacked below |
tiled |
All panes in equal-sized grid |
even-horizontal |
All panes side by side |
even-vertical |
All panes stacked vertically |
Example: Horizontal layout for wide screens:
{
"tmux": {
"enabled": true,
"layout": "main-horizontal",
"main_pane_size": 50
}
}
Example: Tiled layout for maximum parallelism:
{
"tmux": {
"enabled": true,
"layout": "tiled",
"main_pane_size": 50
}
}
Start tmux and OpenCode:
tmux
opencode --port 4096
Ask the Orchestrator to delegate work:
Please analyze this codebase and create a documentation structure.
Watch panes spawn automatically:
# List all panes (in another terminal)
tmux list-panes -a
# Switch to specific pane (in tmux)
Ctrl+B Arrow Keys # Navigate between panes
Ctrl+B % # Split pane horizontally
Ctrl+B " # Split pane vertically
Ctrl+B z # Zoom/unzoom pane
Ctrl+B c # Create new window
Ctrl+B n/p # Next/previous window
# Detach from tmux session (keep it running)
Ctrl+B d
# Reattach to your session later
tmux attach
# Or specify which session
tmux attach -t 0
For different projects on different ports:
# Project 1
tmux new -s project1
opencode --port 4096
# Detach and create Project 2
Ctrl+B d
tmux new -s project2
opencode --port 4097
# Switch between projects
tmux switch -t project1
tmux switch -t project2
# List all sessions (in another terminal)
tmux list-sessions
# Switch to specific session (in tmux)
Ctrl+B s # list sessions and select
Ctrl+B ( # switch to previous session
Ctrl+B ) # switch to next session
Ctrl+B $ # rename current session
Ctrl+B d # detach from current session
Problem: No panes are spawning
Solutions:
Verify tmux integration is enabled:
cat ~/.config/opencode/oh-my-opencode-slim.json | grep tmux # (or .jsonc)
Check port configuration:
# Ensure port matches
echo $OPENCODE_PORT # Should be 4096 by default
opencode --port 4096 # Should match
Verify you're running inside tmux:
echo $TMUX # Should show something, not empty
Check OpenCode logs:
tail -f ~/.config/opencode/logs/opencode.log
Problem: Tmux panes remain open after tasks complete, or opencode attach processes accumulate
This issue is fixed in the latest version. The session lifecycle now properly closes panes and terminates processes.
To verify the fix is working:
# After running some background tasks, check for orphans
ps aux | grep "opencode attach" | grep -v grep
# Should return no results
# Check active tmux panes
tmux list-panes
# Should only show your main session pane(s)
If you still see orphaned processes:
Kill all orphaned processes:
pkill -f "opencode attach"
Close all ghost panes:
# In tmux, close panes manually
tmux kill-pane -t <pane-id>
Restart OpenCode with the updated plugin
Technical Details: The fix implements proper session lifecycle management:
session.abort() is called after task completionsession.deleted eventsSee AGENTS.md for implementation details.
Problem: "Port already in use" or agents not connecting
Solutions:
Use a different port:
export OPENCODE_PORT=5000
opencode --port 5000
Kill existing OpenCode processes:
pkill -f "opencode"
Check for conflicting services:
netstat -tulpn | grep 4096
Problem: Can't create or attach to tmux sessions
Solutions:
Install tmux: ```bash
sudo apt install tmux
# macOS brew install tmux
# Or use the package manager that comes with your distribution
2. **Check tmux version:**
```bash
tmux -V # Should be 1.8 or higher
bash
rm -f ~/.tmux.conf
tmux kill-server
tmux
Problem: Panes don't arrange as expected
Solutions:
Try different layouts:
{
"tmux": {
"enabled": true,
"layout": "tiled",
"main_pane_size": 40
}
}
Manual layout adjustment:
# In tmux, resize panes
Ctrl+B Alt+Arrow Keys
Clear all panes and restart:
tmux kill-pane -a
# Restart OpenCode
Problem: Too many panes or slow performance
Solutions:
Reduce pane size for main window:
{
"tmux": {
"enabled": true,
"layout": "main-vertical",
"main_pane_size": 40
}
}
Limit background tasks:
# In OpenCode, use fewer parallel operations
# Or configure agents to be more sequential
Clean up old panes:
# Kill all panes except current
tmux kill-pane -a
Create ~/.tmux.conf for custom behavior:
# Enable mouse support
set -g mouse on
# Custom key bindings
bind-key r source-file ~/.tmux.conf
# Better colors
set -g default-terminal "screen-256color"
# Status bar customization
set -g status-right "#H %Y-%m-%d %H:%M"
# Pane navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
Watch specific agents more closely:
# Monitor all agent panes
watch -n 1 'tmux list-panes -a -F "#{pane_current_command} (#{pane_index})"'
# Watch OpenCode output specifically
tmux list-panes -a | grep opencode
# Monitor background tasks
tmux list-panes -a | grep background
The plugin provides background task tools that work seamlessly with tmux:
| Tool | Description | Tmux Integration |
|---|---|---|
background_task |
Launch agents asynchronously | Spawns panes for monitoring |
background_output |
Check task results | Output appears in panes |
background_cancel |
Stop running tasks | Cleans up panes |
#!/bin/bash
# Auto-start script for OpenCode with tmux
# Create dedicated session
tmux new -d -s opencode
# Start OpenCode in the session
tmux send-keys -t opencode:0 'opencode --port 4096' Enter
# Wait and attach
sleep 2
tmux attach -t opencode
# Monitor OpenCode logs in real-time
tmux split-window -h
tmux send-keys 'tail -f ~/.config/opencode/logs/opencode.log' Enter
# Switch back to main pane
tmux select-pane -L
Create custom pane arrangements:
# In tmux, create a 3-pane layout
tmux split-window -h
tmux split-window -v
tmux select-pane -L
# Save the layout
tmux save-buffer ~/my-layout.txt
# Restore later
tmux load-buffer ~/my-layout.txt
main-vertical or main-horizontal layouts for better focusmain_pane_size based on your screen resolutionCtrl+B z to zoom into specific panes