Repository navigation
Description
What I want
Native, first-class support for spawning swarm teammates as interactive tmux panes in the same window as the coordinator — the way Claude Code does it. Today swarm spawn works, but the teammate sessions do not appear alongside the coordinator on one screen, so there is no way to watch several agents work at once without manual shell glue.
Why this matters
The value of a swarm is observability while it runs. With headless/inline spawns I get a report at the end; with panes I can see an agent go down a wrong path and correct it immediately. Claude Code's multi-pane view is the single biggest ergonomic difference today.
Current state (v0.67.1) — this is mostly already built
Digging through the binary and testing on tmux 3.7b, almost all the machinery exists:
- The binary already says: "Without a hook, clients inside tmux automatically use a right-side pane."
[terminal] spawn_hook/focus_hookexist and receive<hook> <jcode-binary> <args...>plusJCODE_SPAWN_SESSION_ID,JCODE_SPAWN_TITLE,JCODE_SPAWN_CWD,JCODE_SPAWN_PROGRAM,JCODE_SPAWN_COMMAND.TMUX/TMUX_PANEare already probed alongside Zellij, kitty, WezTerm, Ghostty, herdr.- The documented example is
spawn_hook = "tmux new-window"— a window per agent, not a pane.
Two things block the out-of-the-box experience:
[agents] swarm_spawn_modedefaults to"inline"(there is even a one-time migration stringswarm_spawn_mode default migration: visible -> inline). Inline is in-process with no window, so no spawn hook ever fires and the tmux auto-pane path is unreachable. This is the actual root cause, and it is not discoverable — you have to know to flip it to"visible"first.- Naive
tmux split-window -hcollapses geometry. Measured in a 200x50 window: pane widths went 100 → 49 → 24 → 12 → 11 columns after 4 agents. Usable tiling needstmux select-layout tiledafter each split.
Working config today (for anyone hitting this)
[agents]
swarm_spawn_mode = "visible"
[terminal]
spawn_hook = "~/bin/jcode-tmux-pane"#!/bin/sh
# jcode spawn_hook: each spawned session becomes a tiled tmux pane in the CURRENT window.
set -eu
if [ -z "${TMUX:-}" ] && [ -z "${TMUX_PANE:-}" ]; then
exit 1 # not in tmux -> non-zero lets jcode fall back to its own terminal detection
fi
TARGET="${TMUX_PANE:-}"
CWD="${JCODE_SPAWN_CWD:-$PWD}"
if [ -n "$TARGET" ]; then
tmux split-window -h -t "$TARGET" -c "$CWD" "$@"
else
tmux split-window -h -c "$CWD" "$@"
fi
tmux select-layout tiled
[ -n "${JCODE_SPAWN_TITLE:-}" ] && tmux select-pane -T "$JCODE_SPAWN_TITLE" 2>/dev/null || true
exit 0Verified: 3 simulated spawns produced 4 panes at ~100x24 with pane titles set from JCODE_SPAWN_TITLE; outside tmux the hook exits 1 and jcode correctly falls back to built-in terminal detection.
Proposed
swarm_spawn_mode = "tmux"(or make"visible"detect tmux natively) that does split +select-layout tiled+select-pane -T "$JCODE_SPAWN_TITLE"internally, with no user shell script.[agents] tmux_layout=tiled|even-horizontal|even-vertical|main-vertical, so the coordinator can keep a large main pane with teammates tiled beside it.- Pane lifecycle tied to session lifecycle — pane closes (or is marked dead, per a
tmux_close_on_exitsetting) when the teammate reachesready/stopped/failed, soswarm cleanupdoesn't leave orphan panes. - Cap and overflow behaviour — respect
swarm_max_concurrent_agents(mine is 32, which would be unreadable as panes); beyondtmux_max_panes, spill to new tmux windows rather than shrinking panes to 11 columns. - Discoverability — when
swarm spawnruns inside tmux whileswarm_spawn_mode = "inline", emit a one-time hint that tmux panes are available.
Difficulty
Items 1 and 2 look small: the terminal-detection, hook-invocation, and env-passing paths already exist, so this is mostly a built-in hook implementation plus a config enum. Item 3 (lifecycle) is the one that needs real design, since it touches session teardown and the same cleanup concerns raised in #737 for bg watch sources.
Environment
jcode v0.67.1 (88a19f3), macOS aarch64, tmux 3.7b.
Activity
rameshbaskaran commentedon Aug 5, 2026
Closing for now — I have not yet verified the swarm_spawn_mode=visible + tmux spawn_hook path end-to-end from inside a real tmux session. Will retest and reopen with evidence if the built-in behaviour is insufficient.
rameshbaskaran commentedon Aug 5, 2026
Reopening — with a reproducible bug, not just an ergonomics request
I closed this to test the existing config path first. It turns out the workaround config actively breaks swarm spawning, so this is now a bug report rather than a feature request.
Bug:
swarm_spawn_mode = "visible"and"auto"hang every spawn at "startup queued" when no terminal is availableRepro (jcode v0.67.1, macOS aarch64, session NOT running inside tmux):
~/.jcode/config.toml:swarm spawnany agent.Status: running — startup queuedindefinitely. It never runs, never fails, never times out.swarm stopis the only exit.Three data points from one session, same prompt, same machine, back to back:
swarm_spawn_modeinlinevisibleotter, killed after ~90s)autopanda, killed after ~30s)inline(reverted)peacock)Expected: when the spawn hook exits non-zero, or no terminal can be attached, jcode should fall back to headless/inline and run the agent, or fail fast with a clear error. Silently queueing forever is the worst option — the coordinator's
await_memberswait also never resolves, so a whole swarm can stall on this.Notably
"auto"failing the same way is the more serious half:autois supposed to be the safe "pick something that works" setting, and it picks something that doesn't.The hook itself is fine
To be clear the tmux side works. Driving the same hook manually with simulated
JCODE_SPAWN_*env in a 220x50 tmux window:Correct 2x2 tiling, titles from
JCODE_SPAWN_TITLE, no geometry collapse. So the pane machinery is all present and working — what's missing is (a) a safe fallback when there is no terminal, and (b) native support so users don't need the shell script at all.Original request still stands (see below)
Everything in the original body remains valid:
swarm_spawn_modedefaults toinline, so no hook ever fires and the built-in "right-side pane inside tmux" path is unreachable; the documented example gives a window per agent rather than a pane; and baretmux split-window -hcollapses to 11 columns by the 4th agent withoutselect-layout tiled.Proposed, in priority order now:
inline/headless) or error out, never queue forever. Also applies toauto.swarm_spawn_mode = "tmux"built in (split +select-layout tiled+select-pane -T), no user shell script.[agents] tmux_layout=tiled|even-horizontal|even-vertical|main-vertical.swarm cleanupdoesn't orphan panes.swarm_max_concurrent_agents(mine is 32 — unreadable as panes); pasttmux_max_panes, spill to new windows.inline.Environment: jcode v0.67.1 (88a19f3), macOS aarch64, tmux 3.7b.
1jehuang commentedon Aug 6, 2026
The startup hang should be treated separately from native tmux feature work. A missing hook or terminal must fail fast or fall back instead of remaining startup-queued. Pane layout, lifecycle, and overflow behavior then need a separate product design.
--- — Jcode agent (automated triage), on behalf of @1jehuang
fix: fall back when spawn hooks reject launch (fixes #792)
1jehuang commentedon Aug 6, 2026
The indefinite startup-queued bug is fixed in PR #820. Spawn hooks now get a short startup observation window: an immediate non-zero exit is treated as launch rejection, so built-in terminal detection runs and visible/auto swarm spawning can then fall back to headless execution instead of registering a phantom visible worker. Long-running hooks remain supported and are reaped asynchronously.
Focused hook and visible-session lifecycle tests pass against a clean base. This addresses the hang only; the broader native tmux layout/lifecycle feature remains separate design work.
--- — Jcode agent (automated triage), on behalf of @1jehuang
rameshbaskaran commentedon Aug 6, 2026
Confirming PR #820 fixed this. Live repro just now:
Environment: jcode v0.68.6-dev (02439b4), macOS aarch64, tmux 3.7b, real tmux session (
TMUX_PANE=%0), same config as the original repro (swarm_spawn_mode = "visible",spawn_hook = "~/bin/jcode-tmux-pane").Test:
swarm spawnone worker.Result: new pane opened immediately, tiled side-by-side, correct title (
jcode/grove Chipmunk):Worker reported
ready/okwithin ~3s. No "startup queued" hang, no timeout needed.The hang bug is resolved — closing this specific issue since #820 addressed the exact repro reported here. Re-opening below (or a new issue) if the hang recurs under different conditions.
The broader native-tmux-layout feature items from the original body (built-in
swarm_spawn_mode = "tmux",tmux_layoutconfig, pane lifecycle tied to session, overflow/cap handling pasttmux_max_panes) are still unbuilt — happy to file those as a separate, narrower feature request if useful, since this issue conflated a real bug with a feature wishlist.2 remaining items
fix: unblock SDK 1.2.0 runtime refresh (#842)
chore: sync fork with upstream jcode (fresh merge onto current master) (
fix: fall back when spawn hooks reject launch (fixes 1jehuang#792)
fix: unblock SDK 1.2.0 runtime refresh (1jehuang#842)
fix: fall back when spawn hooks reject launch (fixes 1jehuang#792)
fix: unblock SDK 1.2.0 runtime refresh (1jehuang#842)
fix: fall back when spawn hooks reject launch (fixes 1jehuang#792)
fix: unblock SDK 1.2.0 runtime refresh (1jehuang#842)
fix: fall back when spawn hooks reject launch (fixes 1jehuang#792)
fix: unblock SDK 1.2.0 runtime refresh (1jehuang#842)
fix: fall back when spawn hooks reject launch (fixes 1jehuang#792)
fix: unblock SDK 1.2.0 runtime refresh (1jehuang#842)
fix: fall back when spawn hooks reject launch (fixes 1jehuang#792)
fix: unblock SDK 1.2.0 runtime refresh (1jehuang#842)
fix: unblock SDK 1.2.0 runtime refresh (1jehuang#842)