fix: party log --stop closes only the pipes it opened

Start already skipped panes the host had piped for other purposes,
but --stop swept every pane, killing pipes party log never owned.
Record the pane ids we pipe in .log-panes inside the per-party dir
and close exactly those on --stop; the file dies with the dir.
This commit is contained in:
veg 2026-07-11 16:54:57 +00:00
parent fbe8317fee
commit 6c48777553
2 changed files with 24 additions and 6 deletions

20
party
View file

@ -1092,6 +1092,7 @@ EOF
resolve_authoritative_party "$partyname" || exit 1
logfile="${RR_SOCKET%/sock}/log"
_lg_panesfile="${RR_SOCKET%/sock}/.log-panes"
if [ "$stop" = 1 ]; then
# No log file means logging was never started this run; don't
@ -1101,12 +1102,16 @@ EOF
echo "party log: nothing was being logged."
return 0
fi
# pipe-pane with no command closes a pane's pipe; harmless on
# panes that were never piped.
"$PARTY_TMUX" -S "$RR_SOCKET" list-panes -s -t "$RR_PARTY_NAME" -F '#{pane_id}' \
| while read -r _lg_p; do
"$PARTY_TMUX" -S "$RR_SOCKET" pipe-pane -t "$_lg_p"
done
# Close only the panes we recorded as ours; a pane the host
# piped for their own purposes was never listed here and must
# be left alone. `|| :` covers a recorded pane that's since
# been killed, which would otherwise abort the loop under -e.
if [ -s "$_lg_panesfile" ]; then
while read -r _lg_p; do
"$PARTY_TMUX" -S "$RR_SOCKET" pipe-pane -t "$_lg_p" || :
done < "$_lg_panesfile"
rm -f "$_lg_panesfile"
fi
log_notify stopped
echo "Logging stopped. Transcript: $logfile"
return 0
@ -1128,10 +1133,13 @@ EOF
# already-piped panes while still attaching new ones. The path is
# single-quoted for the server-side sh: a quote in PARTY_SOCKET_DIR
# is accepted breakage, same as the status-right widget.
# Record which panes we pipe so --stop closes only our own pipes,
# never one the host opened for their own purposes.
"$PARTY_TMUX" -S "$RR_SOCKET" list-panes -s -t "$RR_PARTY_NAME" -F '#{pane_pipe} #{pane_id}' \
| while read -r _lg_piped _lg_p; do
[ "$_lg_piped" = 1 ] && continue
"$PARTY_TMUX" -S "$RR_SOCKET" pipe-pane -t "$_lg_p" "cat >> '$logfile'"
echo "$_lg_p" >> "$_lg_panesfile"
done
log_notify started
echo "Logging to $logfile"