Preserve live Pi panes on tmux command drift - #189
Conversation
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.
tmux can briefly report a Pi pane's foreground command as the shell or a transient child even while the long-lived Pi process is still alive below the pane shell. Reconciliation was treating that as agent exit and deleting the state file, which made the sidebar lose the Pi spinner during active work. Keep cached Pi state when the pane shell still has a live Pi descendant, and only delete on command drift once the Pi process is actually gone. Builds on raine#184 (process_tree module).
|
The underlying issues are still separate from #184, but neither PR is ready unchanged. #189 addresses a real command-drift issue, but the current branch includes #184 and depends on its #186 is independent of #184, so the notification feature is still valid. The dependency note in its description is stale. It does still need consideration for existing extension upgrades and nested sessions potentially producing their own notifications. I’ll review whether it makes sense to rework them independently or close them rather than preserving the current implementations. |
|
Closing this stale PR. It depends on the now-closed #184 and needs to be rewritten as a standalone fix against current main. |
Summary
piagent state when tmux briefly reports the pane's foreground command as the shell or a transient tool command, as long as the pane shell still has a live Pi descendantBug
tmux can transiently report a live Pi pane as
zsh(or a tool subprocess) even while the long-lived Pi process is still running below the pane shell. Reconciliation treated that foreground-command change as agent exit and deleted the state file, so the sidebar lost the Pi spinner mid-work.Tests
cargo test --bin workmux process_tree --quietcargo test --bin workmux store --quietcargo test --quiet -- --test-threads=1(a pre-existingPI_CONFIG_DIRenv-var race in config tests requires serial execution; unrelated to this change)Builds on #184 (adds
has_pi_descendantto theprocess_treemodule). Merge after #184.Split out of #184 where it was bundled with the nested-done guard.