feat(subagents): add herdr terminal multiplexer support - #57
0xRichardH wants to merge 1 commit into
Conversation
Extract herdr into its own backend module (herdr.ts) and wire it into the mux dispatcher (cmux.ts). Herdr surfaces are created as new tabs with --no-focus so parallel subagent spawns get full tabs instead of ever-narrower splits, and focus stays on the parent pane. herdr.ts owns all herdr-specific CLI integration: - Runtime detection (HERDR_ENV + herdr in PATH) - Surface creation (tab create / pane split) - Command delivery (pane run — atomic text + Enter) - Screen reading (pane read --source visible) - Escape delivery, pane close, tab/workspace rename - Env-var-first current pane info with subprocess fallback cmux.ts adds herdr to MuxBackend, getMuxBackend(), muxSetupHint(), and dispatches to herdr.ts in createSurface, createSurfaceSplit, sendCommand, sendEscape, readScreen, readScreenAsync, closeSurface, renameCurrentTab, and renameWorkspace. Integration harness probes herdr and implements focus/focused-surface helpers. The focus-preservation test is skipped for herdr/wezterm because neither exposes absolute pane focusing via CLI. README documents herdr as a supported multiplexer. Tested: 133 unit tests pass, 8/8 herdr mux-surface integration tests pass in a live herdr session.
|
@HazAT Let's proceed, as everything is working. |
|
I tested this on Herdr 0.8.0 and opened a follow-up PR against this PR's head branch: 0xRichardH#29. It fixes Herdr-vs-inherited-cmux precedence, explicit source-pane handling, left/up placement and cleanup, hidden-tab reads, and adds live focus/layout plus failure-path coverage (135 unit tests and 10 Herdr mux integration tests passing). |
|
Hey @0xRichardH — clean implementation, thanks for putting this together. One thing worth flagging before this can land against current herdr: This targets herdr 0.7.1, but herdr's CLI changed shape in 0.8.x. Specifically:
I've been running a parallel implementation targeting 0.8.x (verified live against herdr 0.8.2) here:
The two take different approaches (you use a dedicated herdr.ts module; I branched inline in cmux.ts), but the functional deltas worth your attention:
Small nod: --source visible on pane read is a nice touch — I'd happily borrow it. Happy to sync up. If it helps, I can open a PR against your branch with just the 0.8.x id/layout changes, or share the diff directly. Which direction would you prefer? |
What
Adds herdr as a first-class mux backend alongside cmux/tmux/zellij/wezterm.
How
New file:
pi-extension/subagents/herdr.ts— all herdr-specific CLI integration, extracted into its own module per SRP.HERDR_ENV=1+herdrin PATH)herdr tab create --no-focus) so parallel spawns get full tabs instead of ever-narrower splitsherdr pane run(atomic text + Enter in one socket request)herdr pane read --source visible(reliable for freshly-created panes)HERDR_PANE_ID/HERDR_TAB_ID/HERDR_WORKSPACE_ID) with subprocess fallbackpi-extension/subagents/cmux.ts— adds"herdr"toMuxBackend,getMuxBackend(),muxSetupHint(), and dispatches toherdr.tsin all mux operations. No herdr logic leaks into the dispatcher.test/integration/harness.ts— probes herdr ingetAvailableBackends(), implementsfocusSurface/getFocusedSurface/getSurfacePanefor herdr.test/integration/mux-surface.test.ts— skips the focus-preservation test for herdr/wezterm (neither exposes absolute pane focusing via CLI).test/test.ts— herdr detection and JSON response parsing unit tests in a dedicateddescribe("herdr.ts")block.README.md— documents herdr as a supported multiplexer.Bug found and fixed during development
hasCommandinherdr.tsinitially usedexecFileSync("command", ["-v", ...])which fails becausecommandis a shell builtin, not a binary — Node'sexecFileSyncdoesn't invoke a shell. This silently broke herdr detection (returnedfalseeven inside a live herdr session). Fixed to useexecSync(\command -v ...`)(shell form) matchingcmux.ts`.Test results
Verified end-to-end in a live herdr 0.7.1 session: create → send → read → close, rename tab/workspace, escape delivery.