From 6c48777553e146cebca3fdf101e112ecf046675c Mon Sep 17 00:00:00 2001 From: veg Date: Sat, 11 Jul 2026 16:54:57 +0000 Subject: [PATCH] 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. --- party | 20 ++++++++++++++------ tests/87-log.bats | 10 ++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/party b/party index 671d319..1e89598 100755 --- a/party +++ b/party @@ -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" diff --git a/tests/87-log.bats b/tests/87-log.bats index ab5cd2a..410a938 100644 --- a/tests/87-log.bats +++ b/tests/87-log.bats @@ -79,6 +79,16 @@ poll_for() { grep -q marker-KEEP "$saved" } +@test "log --stop leaves a manually piped pane alone" { + "$PARTY_BIN" host bystander + manual="$PARTY_TMP/manual-pipe.out" + tmux -S "$(sock_of bystander)" pipe-pane -t bystander "cat >> '$manual'" + "$PARTY_BIN" log + "$PARTY_BIN" log --stop + tmux -S "$(sock_of bystander)" send-keys -t bystander 'echo marker-MANUAL' Enter + poll_for "$manual" marker-MANUAL +} + @test "close without a transcript stays silent about rescue" { export HOME="$PARTY_TMP/home" mkdir -p "$HOME"