Robust tmux orchestrator/worker targeting under any config + tolerant tasks.json parsing #4

Closed
UDLRcodes wants to merge 11 commits from fix/tmux-targeting-and-tasks-robustness into main
UDLRcodes commented 2026-06-21 07:35:39 +00:00 (Migrated from github.com)

Summary

Two related robustness fixes so superharness behaves correctly under real-world
tmux configurations and tolerates the freeform tasks.json the orchestrator writes.

1. Robust tmux orchestrator/worker targeting (fix)

superharness hardcoded a superharness:0 window and %0 orchestrator pane. Under
any non-default tmux config — base-index != 0, an embedded session, window reorg,
or break-pane — those targets were wrong, producing can't find window: 0 /
can't find pane: %0 failures, scanning and stealing user-created windows, and —
worst — a finishing worker tearing down the entire session.

  • Resolve the orchestrator window/pane dynamically and tag panes at creation with
    @sh_orchestrator / @sh_worker, so targeting survives base-index, embedded
    sessions, reorg, and break-pane. Replaces the hardcoded superharness:0 /
    window_index targets across the spawn, layout, min-pane-size, and terminal-size paths.
  • Isolate workers from user-created windows: the heartbeat scanner and compaction
    now act only on @sh_worker-tagged panes, so user windows are never scanned,
    surfaced, or stolen.
  • Resolve toggle-mode / F1 via orchestrator_pane_id() with validated fallbacks
    (pane tag → echo-back-validated env var → lowest pane id) instead of a literal %0.
  • Worker exit now kills its own pane via $TMUX_PANE (guarded against an empty
    value) instead of an untargeted tmux display-message -p '#{pane_id}', which
    resolved to the active (orchestrator) pane and crashed the whole session when a
    worker finished.
  • Update the generated AGENTS.md template (assets/agents_template.md) to document
    the tagging + dynamic resolution and drop its hardcoded %0 references.

2. Tolerant tasks.json parsing (feat)

The orchestrator writes tasks.json freeform, so the tasks modal and the
planning-mode bootstrap now accept either top-level shape:

  • the canonical { "tasks": [ ... ] } wrapper object, or
  • a legacy bare [ ... ] array.

Empty / missing / null content is treated as "no plan yet" so planning mode opens,
and the planning prompt now spells out the wrapper form so new plans are written canonically.

Testing

  • 109/109 unit tests pass, including new coverage for the worker-exit command.
  • 3 fully isolated shell regression tests pass — base_index, toggle_mode,
    worker_exit. Each reproduces its original bug, then proves the fix. The
    worker_exit test runs against a throwaway tmux server (unset TMUX, fresh
    TMUX_TMPDIR, dedicated -L socket) so it can never touch the user's real session.
## Summary Two related robustness fixes so superharness behaves correctly under real-world tmux configurations and tolerates the freeform `tasks.json` the orchestrator writes. ## 1. Robust tmux orchestrator/worker targeting (`fix`) superharness hardcoded a `superharness:0` window and `%0` orchestrator pane. Under any non-default tmux config — `base-index != 0`, an embedded session, window reorg, or break-pane — those targets were wrong, producing `can't find window: 0` / `can't find pane: %0` failures, scanning and stealing user-created windows, and — worst — a finishing worker tearing down the **entire session**. - Resolve the orchestrator window/pane dynamically and tag panes at creation with `@sh_orchestrator` / `@sh_worker`, so targeting survives base-index, embedded sessions, reorg, and break-pane. Replaces the hardcoded `superharness:0` / `window_index` targets across the spawn, layout, min-pane-size, and terminal-size paths. - Isolate workers from user-created windows: the heartbeat scanner and compaction now act only on `@sh_worker`-tagged panes, so user windows are never scanned, surfaced, or stolen. - Resolve toggle-mode / F1 via `orchestrator_pane_id()` with validated fallbacks (pane tag → echo-back-validated env var → lowest pane id) instead of a literal `%0`. - Worker exit now kills its **own** pane via `$TMUX_PANE` (guarded against an empty value) instead of an untargeted `tmux display-message -p '#{pane_id}'`, which resolved to the active (orchestrator) pane and crashed the whole session when a worker finished. - Update the generated `AGENTS.md` template (`assets/agents_template.md`) to document the tagging + dynamic resolution and drop its hardcoded `%0` references. ## 2. Tolerant tasks.json parsing (`feat`) The orchestrator writes `tasks.json` freeform, so the tasks modal and the planning-mode bootstrap now accept either top-level shape: - the canonical `{ "tasks": [ ... ] }` wrapper object, or - a legacy bare `[ ... ]` array. Empty / missing / null content is treated as "no plan yet" so planning mode opens, and the planning prompt now spells out the wrapper form so new plans are written canonically. ## Testing - **109/109** unit tests pass, including new coverage for the worker-exit command. - **3 fully isolated shell regression tests** pass — `base_index`, `toggle_mode`, `worker_exit`. Each reproduces its original bug, then proves the fix. The `worker_exit` test runs against a throwaway tmux server (unset `TMUX`, fresh `TMUX_TMPDIR`, dedicated `-L` socket) so it can never touch the user's real session.

Pull request closed

Sign in to join this conversation.
No description provided.