fix: party list tags the group only when parties differ on it

The tag was shown whenever a party's group differed from
TMUX_PARTY_GROUP, which falls back to 'party' when unset. Since host
time auto-selects the group, a box gating on 'staff' tagged every
line. Compare the visible parties with each other instead.
This commit is contained in:
veg 2026-09-21 09:32:48 +00:00
parent 851cef6941
commit 9b85485ee8
2 changed files with 35 additions and 11 deletions

29
party
View file

@ -1520,7 +1520,7 @@ cmd_detach() {
} }
cmd_list() { cmd_list() {
found=0 found=0 lines='' first_group='' mixed=0
for rec in $(roster_list); do for rec in $(roster_list); do
roster_read "$rec" || continue roster_read "$rec" || continue
state=$(party_conn_state "$RR_SOCKET") state=$(party_conn_state "$RR_SOCKET")
@ -1535,29 +1535,36 @@ cmd_list() {
# the FS perimeter alone. # the FS perimeter alone.
list_group="${RR_GROUP:-$TMUX_PARTY_GROUP}" list_group="${RR_GROUP:-$TMUX_PARTY_GROUP}"
id -nG "$USER" 2>/dev/null | tr ' ' '\n' | grep -qx "$list_group" || continue id -nG "$USER" 2>/dev/null | tr ' ' '\n' | grep -qx "$list_group" || continue
# Show the group only when it differs from the env/default, to # The group tag only earns its column when the visible parties
# keep the common case uncluttered. # disagree on it. Which group gates a party is decided per host
group_tag= # (auto-selection), so there is no default to compare against:
if [ -n "$RR_GROUP" ] && [ "$RR_GROUP" != "$TMUX_PARTY_GROUP" ]; then # tag every line, then strip the tags below unless they differ.
group_tag=" [group=$RR_GROUP]" [ -n "$first_group" ] || first_group="$list_group"
fi [ "$list_group" = "$first_group" ] || mixed=1
group_tag=" [group=$list_group]"
if [ "$state" = ok ]; then if [ "$state" = ok ]; then
attendees=$("$PARTY_TMUX" -S "$RR_SOCKET" list-clients 2>/dev/null | wc -l | tr -d ' ') attendees=$("$PARTY_TMUX" -S "$RR_SOCKET" list-clients 2>/dev/null | wc -l | tr -d ' ')
printf '%-12s %-30s %s attendee(s)%s\n' \ line=$(printf '%-12s %-30s %s attendee(s)%s' \
"$RR_HOST_USER" "$RR_PARTY_NAME" "$attendees" "$group_tag" "$RR_HOST_USER" "$RR_PARTY_NAME" "$attendees" "$group_tag")
else else
# Live server, connection refused: we can't count attendees # Live server, connection refused: we can't count attendees
# (list-clients is behind the auth gate: its empty stdout # (list-clients is behind the auth gate: its empty stdout
# used to render here as a bogus "0 attendee(s)"), but the # used to render here as a bogus "0 attendee(s)"), but the
# party is real and the caller can ask for an invite. # party is real and the caller can ask for an invite.
printf '%-12s %-30s invite-only (ask %s)%s\n' \ line=$(printf '%-12s %-30s invite-only (ask %s)%s' \
"$RR_HOST_USER" "$RR_PARTY_NAME" "$RR_HOST_USER" "$group_tag" "$RR_HOST_USER" "$RR_PARTY_NAME" "$RR_HOST_USER" "$group_tag")
fi fi
lines="$lines$line
"
found=$((found+1)) found=$((found+1))
done done
if [ "$found" -eq 0 ]; then if [ "$found" -eq 0 ]; then
echo "no parties found on this host." echo "no parties found on this host."
elif [ "$mixed" = 1 ]; then
printf '%s' "$lines"
else
printf '%s' "$lines" | sed 's/ \[group=[^]]*\]$//'
fi fi
} }

View file

@ -855,3 +855,20 @@ STUB
run "$PARTY_BIN" detach nobody --party alpha run "$PARTY_BIN" detach nobody --party alpha
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "list shows the group tag only when visible parties differ on it" {
"$PARTY_BIN" host solo
run "$PARTY_BIN" list
[ "$status" -eq 0 ]
[[ "$output" == *"solo"* ]]
[[ "$output" != *"[group="* ]]
# A second party gated on another of the caller's groups.
other=$(id -nG | tr ' ' '\n' | grep -vx "$TMUX_PARTY_GROUP" | head -1)
[ -n "$other" ] || skip "caller is in a single group"
"$PARTY_BIN" host duo --group "$other"
run "$PARTY_BIN" list
[ "$status" -eq 0 ]
[[ "$output" == *"solo"*"[group=$TMUX_PARTY_GROUP]"* ]]
[[ "$output" == *"duo"*"[group=$other]"* ]]
}