Skip to content

Preserve live Pi panes on tmux command drift - #189

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

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).
@raine

raine commented Jul 26, 2026

Copy link
Copy Markdown
Owner

@aserper since #184 was closed, what should we do with this and #186

Are these still valid?

@aserper

aserper commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

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 process_tree module. It would need to be rebased and rewritten as a standalone fix.

#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.

@aserper

aserper commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Closing this stale PR. It depends on the now-closed #184 and needs to be rewritten as a standalone fix against current main.

@aserper aserper closed this Sep 3, 2026
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.

2 participants