Skip to content

Preserve live Pi panes on tmux command drift#189

Open
aserper wants to merge 2 commits into
raine:mainfrom
aserper:fix/pi-pane-command-drift
Open

Preserve live Pi panes on tmux command drift#189
aserper wants to merge 2 commits into
raine:mainfrom
aserper:fix/pi-pane-command-drift

Conversation

@aserper

@aserper aserper commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Keep cached pi agent 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 descendant
  • Only delete on command drift once the Pi process is actually gone

Bug

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 --quiet
  • cargo test --bin workmux store --quiet
  • cargo test --quiet -- --test-threads=1 (a pre-existing PI_CONFIG_DIR env-var race in config tests requires serial execution; unrelated to this change)

Builds on #184 (adds has_pi_descendant to the process_tree module). Merge after #184.

Split out of #184 where it was bundled with the nested-done guard.

aserper added 2 commits June 28, 2026 23:03
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant