diff --git a/party b/party index 65f1f20..9a494d1 100755 --- a/party +++ b/party @@ -567,12 +567,12 @@ tmux="$PARTY_TMUX" EOF cat >> "$notify_script" <<'EOF' # 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. -# "joined", "left", "started logging", "stopped logging") -sock="$1"; user="$2"; verb="$3" +# of the party server. Args: $1 = socket, $2 = user, $3 = verb +# ("joined", "left", "started logging"), $4 = object (default "the party") +sock="$1"; user="$2"; verb="$3"; obj="${4:-the party}" "$tmux" -S "$sock" list-clients -F '#{client_name}' 2>/dev/null \ | 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 EOF chmod 0755 "$notify_script" @@ -1105,11 +1105,12 @@ EOF # Tell everyone in the room when recording starts or stops: a # transcript nobody knew about is the kind of surprise the social # design exists to avoid. Reuses the .party-notify script generated at -# host time, so the broadcast reads "$USER started logging the party" -# / "$USER stopped logging the party". Tolerant of failure: a missing -# or unreadable notify script shouldn't abort logging. +# host time; the broadcast reads "$USER started logging this party". +# Tolerant of failure: a missing or unreadable notify script shouldn't +# abort logging. 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() { diff --git a/tests/95-stub-roundtrip.bats b/tests/95-stub-roundtrip.bats index e40a5c7..f35d1a1 100644 --- a/tests/95-stub-roundtrip.bats +++ b/tests/95-stub-roundtrip.bats @@ -43,6 +43,11 @@ case "$*" in # party process while it waits on us, mid-setup. [ -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 "*) # Caller is fishing for #{pid}; emit the sleeper's PID. echo "$FAKE_SERVER_PID" @@ -872,3 +877,23 @@ STUB [[ "$output" == *"solo"*"[group=$TMUX_PARTY_GROUP]"* ]] [[ "$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" +}