fix(status): keep pi subagent panes working - #184
Conversation
|
Thanks. How come all this logic is needed for Pi? |
Pi runs subagents as separate `pi` processes in the same tmux pane and loads the same status extension in parent and child. Both fire identical `agent_start` / `agent_end` hooks, and the events carry no run or parent id, so a child finishing was indistinguishable from the parent finishing and marked the pane done early. The extension now passes the emitting process id with `--from-pid`. A top-level Pi has no Pi ancestor, so `done` stays `done`; a child Pi has a live parent Pi ancestor, so its `done` is kept as `working` until the parent completes. The guard is stateless and Linux-only (reads `/proc`), matching the existing `multiplexer::tmux::process_ancestors` helper.
0098c8a to
e891fac
Compare
|
The root issue is that Pi runs subagents as separate That said, this PR had ended up bundling two unrelated fixes — a tmux command-drift preserve and an atomic-write temp-file fix. I've split those out into #188 and #189 and slimmed this PR down to just the nested-done guard. |
|
Pi doesn't actually ship its own subagent functionality though right? Various extensions do this; i don't think there's a universal implementation, though running as a separate process in the same pane is probably a common and reasonable implementation. |
|
You are correct, but that's how I've seen it implemented in pi and other harnesses as well. There's no "real" multi threading here... |
|
I'm a bit confused as to what to do with this PR, found some issues in review:
|
|
After looking through the review findings, I agree that the process-tree approach is too narrow. It works for separate-process Pi subagents on an unsandboxed Linux host, but it cannot reliably handle same-process OMP sessions, sandbox PID namespaces, or other platforms. It would also require an upgrade path for existing installed extensions. I think this is better handled by the extension launching the nested agent, since it knows whether the session is a child and can disable Workmux status updates there. Closing this rather than adding more Workmux-side heuristics. |
Summary
--from-piddoneevent is kept asworkingwhile a parent Pi ancestor is still alive; a top-level Pidonestaysdone/proc), matching the existingmultiplexer::tmux::process_ancestorshelperBug
Pi runs subagents as separate
piprocesses in the same tmux pane and loads the same status extension in parent and child. Both fire identicalagent_start/agent_endhooks, and the events carry no run or parent id, so a child subagent finishing was indistinguishable from the parent finishing and marked the pane done early.With no id in the event, the process tree is the only signal available to tell them apart: a top-level Pi has no Pi ancestor, a subagent Pi does.
Tests
cargo test --bin workmux process_tree --quietcargo test --bin workmux set_window_status --quietcargo test --quietTwo related fixes that were previously bundled here have been split into their own PRs: