Automatic tmux pane management for opencode subagents.
When running inside tmux, this plugin automatically spawns new panes for subagent sessions and cleans them up when sessions end.
git clone https://github.com/dna113p/opencode-tmux-panes.git
cd opencode-tmux-panes
bun install
bun run build
ln -sf "$(pwd)/dist/index.js" ~/.config/opencode/plugins/opencode-tmux-panes.jsThe plugin automatically manages tmux panes when running inside tmux. No configuration required.
- When a subagent session is created, the plugin spawns a new tmux pane
- The new pane runs
opencode attachto connect to the subagent - Panes are arranged using the configured layout (default: main-vertical)
- When sessions end, panes are automatically cleaned up
Add to your opencode settings:
{
"plugins": {
"opencode-tmux-panes": {
"layout": "main-vertical",
"main_pane_size": 60,
"exclude": ["explore-*", "quick-*"]
}
}
}| Option | Type | Default | Description |
|---|---|---|---|
layout |
string | "main-vertical" |
Tmux layout: main-vertical, main-horizontal, tiled, even-horizontal, even-vertical |
main_pane_size |
number | 60 |
Main pane size percentage (20-80) |
main_pane_min_width |
number | 120 |
Minimum main pane width in columns |
agent_pane_min_width |
number | 40 |
Minimum agent pane width in columns |
exclude |
string[] | [] |
Glob patterns to exclude from pane management |
Plugins can opt out specific sessions from pane management:
await client.session.create({
title: "my-agent",
metadata: { tmux: false } // This session won't get a pane
});- Running inside a tmux session
tmuxbinary available in PATH- opencode >= 1.0.0
After making changes, rebuild with bun run build -- the symlink means opencode will pick up the new build on next launch.
bun run build # rebuild the plugin
bun run typecheck # check types
bun test # run testsThe plugin uses a state-first approach:
- Query: Get actual tmux pane state (source of truth)
- Decide: Pure function determines actions based on state
- Execute: Execute actions with verification
- Update: Update internal cache only after tmux confirms success
MIT