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