From c28101e2e8caff88c191580ddd6c186efcc0e933 Mon Sep 17 00:00:00 2001 From: veg Date: Mon, 21 Sep 2026 09:42:03 +0000 Subject: [PATCH] refactor: direct roster lookups in cmd_role and cmd_who cmd_role's TMUX-socket match and cmd_who's --socket branch each walked every roster via roster_list to find the one record they already knew the path to. Read that record directly instead. roster_read still validates the dir basename and ownership, so a non-party socket falls through to cmd_role's existing fallback loop. --- party | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/party b/party index 0c21411..8654e58 100755 --- a/party +++ b/party @@ -1648,7 +1648,7 @@ cmd_who() { # roster_read overwrites these with the same values on success. RR_HOST_USER="${stripped%%:*}" RR_PARTY_NAME="${stripped#*:}" - rec=$(roster_record_path "$RR_HOST_USER" "$RR_PARTY_NAME") + rec="${sock%/*}/roster" roster_read "$rec" 2>/dev/null || true elif [ -n "$partyname" ]; then find_party_by_name "$partyname" || exit 1 @@ -1740,12 +1740,14 @@ EOF host_sess='' if [ -n "${TMUX:-}" ]; then tmux_sock="${TMUX%%,*}" - for rec in $(roster_list); do - roster_read "$rec" || continue - [ "$(party_conn_state "$RR_SOCKET")" != dead ] || continue - [ "$RR_SOCKET" = "$tmux_sock" ] || continue - sock="$RR_SOCKET"; host_sess="$RR_PARTY_NAME"; break - done + # Direct read rather than a roster_list walk: roster_read already + # validates the dir basename/ownership and returns 1 for a + # non-party path, so a personal tmux socket simply falls through + # to the fallback loop below. + if roster_read "${tmux_sock%/sock}/roster" \ + && [ "$(party_conn_state "$RR_SOCKET")" != dead ]; then + sock="$RR_SOCKET"; host_sess="$RR_PARTY_NAME" + fi fi if [ -z "$sock" ]; then for rec in $(roster_list); do