Skip to content

About

OpenCode V2 TUI plugin: the open session's sub-agents in the sidebar, with open and stop

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

subagents-panel

An OpenCode V2 TUI plugin that lists the open session's sub-agents in the sidebar (role, model, status, run time, tokens, cost) and lets you open or stop them.

The sub-agents panel: one sub-agent waiting for you, two running, two finished

An expanded sub-agent, with its task, status, run time, tokens, and the Open and Stop buttons:

An expanded running sub-agent

Requirements

  • OpenCode V2, run as the terminal UI. Built and tested with OpenCode 2.4.2; other versions are untested.
  • Tested on Linux (WSL 2) only. macOS and native Windows are untested.
  • Git, to download the plugin.

Nothing else: the plugin has no dependencies of its own and uses the copies of solid-js and @opentui that OpenCode ships. Bun is needed only to run the tests (see Development).

Installation

  1. Download the plugin to a folder of your choice:

    git clone https://github.com/ptitan/opencode-subagents-panel.git ~/opencode-plugins/subagents-panel
  2. Open OpenCode's CLI settings file, ~/.config/opencode/cli.json ($XDG_CONFIG_HOME/opencode/cli.json if XDG_CONFIG_HOME is set). If it does not exist, create it with this content:

    {
      "$schema": "https://opencode.ai/v2/cli.json"
    }
  3. Add the plugin to the plugins array, with the absolute path of the folder (no ~). Keep the entries already there. For example, if the file has:

    {
      "$schema": "https://opencode.ai/v2/cli.json",
      "theme": { "name": "opencode", "mode": "dark" },
      "plugins": ["-opencode.notifications"]
    }

    it becomes:

    {
      "$schema": "https://opencode.ai/v2/cli.json",
      "theme": { "name": "opencode", "mode": "dark" },
      "plugins": [
        "-opencode.notifications",
        { "package": "/home/you/opencode-plugins/subagents-panel", "options": {} }
      ]
    }

    If there is no plugins array, add one. options takes the settings of the table below; {} keeps the defaults.

  4. Start OpenCode (or wait a moment if it is already running: valid edits to cli.json reload while the TUI runs).

Check that it works

  • Press ctrl+p and type Sub-agents: the palette lists Sub-agents: settings (and, inside a session, Sub-agents: list and Sub-agents: stop all). Opening Sub-agents: settings shows the settings menu.
  • Press ctrl+p and open Plugins: local.subagents-panel is listed.
  • The panel itself stays hidden as long as the open session has no sub-agent. It appears in the sidebar once the session has started one (the sidebar must be shown: session.sidebar is not hide, and the terminal is wide enough).

Usage

  • Click a line to expand or collapse its block: task, status, run time, tokens, background tasks, cost, and the Open and Stop buttons.
  • Open goes to the sub-agent's session; OpenCode's Go to parent session key (up when the prompt is not focused) comes back.
  • Stop stops the sub-agent and everything it started (nested sub-agents, background shells and jobs), after a confirmation. The parent session and other sessions are not touched.
  • The status symbol is •: orange while running, red on error, dim when finished; a bold ? means the sub-agent waits for you (permission or form) and comes first.
  • +N more (when more sub-agents exist than rows) opens the full list.

Commands, in the palette (ctrl+p) and as slash commands in the prompt:

Command Palette entry Effect
/subpanel-list Sub-agents: list Every sub-agent, with its task, status, time, and tokens. enter opens one, ctrl+d stops the selected one, alt+d stops all.
/subpanel-stop-all Sub-agents: stop all Stops every running sub-agent of the open session, after a confirmation.
/subpanel-settings Sub-agents: settings The settings menu.

The list opened by /subpanel-list

Settings

The settings menu opened by /subpanel-settings

Use /subpanel-settings: the menu lists each setting with its value and where it comes from (menu, cli.json, or default). A change applies at once. Menu values are saved by OpenCode for the TUI (not in cli.json) and win over cli.json; Reset to defaults clears them.

cli.json options are an alternative, for example to share a setup: put them in the plugin entry's options. Invalid values are ignored.

Menu entry cli.json option Default Values
Role labels labels none Label per agent ID, shown in capitals instead of the agent's name. In the menu: pick an agent, type a label; empty text goes back to the default. Labels with emoji, wide, or control characters are refused.
Show provider showProvider false Prefix the model with its provider.
Max model length maxModel 15 6 to 80 columns for the model on a block's line.
Max rows maxRows 6 1 to 50 sub-agents shown in the panel; the rest go to +N more.
Start expanded startExpanded false New blocks start expanded.
Show cost showCost true Show costs.
Confirm before stop confirmStop true Ask before Stop (stop all always asks).
Hide finished hideFinished false Show only running or waiting sub-agents (and their parents).
Position position "top" "top" or "bottom" of the sidebar's content.
— width 42 Maximum line width (the sidebar's width applies if narrower). cli.json only.

Without a label, the role is the agent's name as OpenCode reports it, in capitals (EXPLORE), else its ID. Example with every kind of option:

{
  "package": "/home/you/opencode-plugins/subagents-panel",
  "options": {
    "labels": { "general": "Gen", "explore": "Scout" },
    "position": "bottom",
    "maxRows": 8,
    "width": 40
  }
}

Keyboard shortcuts: with OpenCode 2.4.2, these commands cannot be bound to a key through keybinds in cli.json. The plugin API lets a plugin declare a binding (bind); this plugin declares bind: false.

Update

git -C ~/opencode-plugins/subagents-panel pull

The TUI reloads the plugin when its files change; restart OpenCode if it does not.

Uninstall

  1. Remove the plugin's entry from the plugins array of cli.json.
  2. Delete the plugin folder.
  3. Optional: delete the saved menu values, ~/.local/state/opencode/latest/tui/plugin.local.subagents-panel.settings.json ($XDG_STATE_HOME/opencode/… if XDG_STATE_HOME is set), or use Reset to defaults before removing the plugin.

Troubleshooting

  • No panel: it shows only for a session that has sub-agents, in the sidebar. Check that the commands are in the palette (see Check that it works). If they are not, check the path in cli.json: absolute, pointing to the folder that holds package.json. A wrong path shows no error message; the plugin is simply not loaded.
  • A label is shown as the agent's name instead: the label contains a character that is not one column wide (emoji, wide or control character) and is ignored.

Limitations

  • Shows up to three levels of nested sub-agents. For a session reopened from history, older nested levels are loaded within a bounded number of requests and may be incomplete.
  • Stopping checks the sub-agent's subtree again for about two seconds; something that wakes it up later is not stopped. Stops beyond 500 sessions in a subtree are not guaranteed (a message says so).
  • A resumed sub-agent shows the duration of its latest run only.
  • The commands cannot be bound to a key through keybinds (see Settings).

Details: docs/DETAILS.md.

License

MIT

Development

Type-checking dependencies live in dev/, outside the plugin's resolution path, so that at runtime the plugin keeps using OpenCode's solid-js and @opentui (two Solid instances would break reactivity).

(cd dev && bun install)
bun run typecheck
bun run test      # pure logic, on made-up data; reads nothing from the machine

Files: src/tui.tsx (OpenCode wiring, menu, panel), src/rows.ts (layout), src/settings.ts (settings), src/stop.ts (stopping a subtree).

About

OpenCode V2 TUI plugin: the open session's sub-agents in the sidebar, with open and stop

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages