Skip to content

pane-died / pane-exited hooks with remain-on-exit (tmux parity) #227

@pbolduc

Description

@pbolduc

Problem statement

In tmux, when a pane's child process exits and remain-on-exit is enabled, the pane stays on screen in a "dead" state and hooks such as pane-died (and related events) still run. Automation and plugins often depend on that—for example a pane-died hook that runs respawn-pane after checking #{pane_dead}.

In psmux, pane-died / pane-exited hooks appear to run only when the reaper removes a pane from the layout. If remain-on-exit is on, the child exits but the pane node may stay, so no prune occurs and the hooks may never fire. That breaks workflows and external tests that assume tmux-like behavior.

Commands to reproduce

display-message is shown on an attached client (status / message area). A detached session often has no client, so you will not see the message until you attach—or use a side effect that does not need a TUI.

A. See display-message (requires a client)

  1. Start a detached session whose pane exits quickly:
psmux new-session -d -s repro-session -n test "Start-Sleep -Seconds 2"
  1. Set remain-on-exit and a pane-died hook:
psmux set-option -t repro-session -g remain-on-exit on
psmux set-hook -t repro-session pane-died 'display-message "PANE-DIED-FIRED"'
  1. Attach so messages are visible:
psmux attach -t repro-session
  1. Wait until the initial Start-Sleep has finished (at least ~3 seconds after step 1, or wait after attach if you attached late).

  2. Expected (tmux-like): shortly after the pane's process exits, you should see PANE-DIED-FIRED in the message/status area. Actual: that message may never appear even though the pane is dead with remain-on-exit.

Detach when finished (e.g. prefix + d, or your documented detach command).

B. Observe without relying on the UI (detached-friendly)

psmux set-hook -t repro-session pane-died 'run-shell -b "echo died >> $env:TEMP\psmux-pane-died.txt"'

After the sleep exits, inspect that file for new content.

Optional: repeat the same steps against tmux 3.x with the same session/hook names for comparison.

Acceptance criteria

  1. When a pane's child process exits and remain-on-exit is on, pane-died and pane-exited hooks run in line with tmux semantics for that scenario.
  2. Hooks must not fire repeatedly every idle tick; they should run when the "dead under remain-on-exit" condition is first detected (or match tmux behavior if documented differently).
  3. Firing hooks for remain-on-exit deaths must not imply removing panes or resizing the layout solely because the pane became dead (resize when the tree structure changes, e.g. a pane is actually removed).
  4. With remain-on-exit off, existing behavior for reaping exited panes and firing hooks on removal remains correct.
  5. Add or extend tests (unit and/or integration) that cover hooks firing when a pane becomes dead with remain-on-exit; update compatibility docs if the project maintains them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions