fix: log broadcast says 'this party' again

Routing log_notify through .party-notify had turned the announcement
into 'started logging the party'. The helper takes an optional object
phrase, defaulting to 'the party' for the join/leave hooks, and
log_notify passes 'this party'. Both wordings are now pinned by stub
tests, which had no coverage of the broadcast text before.
This commit is contained in:
veg 2026-09-21 11:37:30 +00:00
parent 733633bd65
commit 471ee5875c
2 changed files with 34 additions and 8 deletions

17
party
View file

@ -567,12 +567,12 @@ tmux="$PARTY_TMUX"
EOF EOF
cat >> "$notify_script" <<'EOF' cat >> "$notify_script" <<'EOF'
# Auto-generated by party. Fan a display-message out to every client # Auto-generated by party. Fan a display-message out to every client
# of the party server. Args: $1 = socket, $2 = user, $3 = verb (e.g. # of the party server. Args: $1 = socket, $2 = user, $3 = verb
# "joined", "left", "started logging", "stopped logging") # ("joined", "left", "started logging"), $4 = object (default "the party")
sock="$1"; user="$2"; verb="$3" sock="$1"; user="$2"; verb="$3"; obj="${4:-the party}"
"$tmux" -S "$sock" list-clients -F '#{client_name}' 2>/dev/null \ "$tmux" -S "$sock" list-clients -F '#{client_name}' 2>/dev/null \
| while read -r c; do | while read -r c; do
"$tmux" -S "$sock" display-message -c "$c" "$user $verb the party" 2>/dev/null || : "$tmux" -S "$sock" display-message -c "$c" "$user $verb $obj" 2>/dev/null || :
done done
EOF EOF
chmod 0755 "$notify_script" chmod 0755 "$notify_script"
@ -1105,11 +1105,12 @@ EOF
# Tell everyone in the room when recording starts or stops: a # Tell everyone in the room when recording starts or stops: a
# transcript nobody knew about is the kind of surprise the social # transcript nobody knew about is the kind of surprise the social
# design exists to avoid. Reuses the .party-notify script generated at # design exists to avoid. Reuses the .party-notify script generated at
# host time, so the broadcast reads "$USER started logging the party" # host time; the broadcast reads "$USER started logging this party".
# / "$USER stopped logging the party". Tolerant of failure: a missing # Tolerant of failure: a missing or unreadable notify script shouldn't
# or unreadable notify script shouldn't abort logging. # abort logging.
log_notify() { log_notify() {
"${RR_SOCKET%/sock}/.party-notify" "$RR_SOCKET" "$USER" "$1 logging" || : "${RR_SOCKET%/sock}/.party-notify" "$RR_SOCKET" "$USER" \
"$1 logging" "this party" || :
} }
cmd_log() { cmd_log() {

View file

@ -43,6 +43,11 @@ case "$*" in
# party process while it waits on us, mid-setup. # party process while it waits on us, mid-setup.
[ -n "${SIGNAL_ON_NEWSESSION:-}" ] && kill -TERM "$PPID" [ -n "${SIGNAL_ON_NEWSESSION:-}" ] && kill -TERM "$PPID"
;; ;;
*"list-clients -F #{client_name}"*)
# Optional injection point for the broadcast tests: pretend one
# client is attached so the notify fan-out has someone to message.
[ -n "${FAKE_CLIENT:-}" ] && echo "$FAKE_CLIENT"
;;
*"display-message -p "*) *"display-message -p "*)
# Caller is fishing for #{pid}; emit the sleeper's PID. # Caller is fishing for #{pid}; emit the sleeper's PID.
echo "$FAKE_SERVER_PID" echo "$FAKE_SERVER_PID"
@ -872,3 +877,23 @@ STUB
[[ "$output" == *"solo"*"[group=$TMUX_PARTY_GROUP]"* ]] [[ "$output" == *"solo"*"[group=$TMUX_PARTY_GROUP]"* ]]
[[ "$output" == *"duo"*"[group=$other]"* ]] [[ "$output" == *"duo"*"[group=$other]"* ]]
} }
@test "log start and stop are announced to attached clients" {
"$PARTY_BIN" host taped
export FAKE_CLIENT=/dev/pts/99
run "$PARTY_BIN" log
[ "$status" -eq 0 ]
grep -q "display-message -c /dev/pts/99 $USER started logging this party$" "$TMUX_LOG"
run "$PARTY_BIN" log --stop
[ "$status" -eq 0 ]
grep -q "display-message -c /dev/pts/99 $USER stopped logging this party$" "$TMUX_LOG"
}
@test "join/leave broadcast keeps its default wording" {
"$PARTY_BIN" host greet
party_dir="$PARTY_SOCKET_DIR/party-$USER:greet.d"
FAKE_CLIENT=/dev/pts/99 "$party_dir/.party-notify" "$party_dir/sock" alice joined
grep -q "display-message -c /dev/pts/99 alice joined the party$" "$TMUX_LOG"
}