From b1e7f46f257c49fd0f7a610c14ec3378ac65e2d5 Mon Sep 17 00:00:00 2001 From: Natalie Date: Sun, 17 May 2026 07:42:01 -0700 Subject: [PATCH] =?UTF-8?q?feat(@scripts):=20=E2=9C=A8=20add=20name=20enri?= =?UTF-8?q?chment=20for=20resume=20picker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- bin/rclaude | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/bin/rclaude b/bin/rclaude index 17e315d..9b79f58 100755 --- a/bin/rclaude +++ b/bin/rclaude @@ -187,6 +187,28 @@ _filter_sessions_to_uuids() { | awk -F'\t' -v r="^($_re)$" '$3 ~ r' } +# Build a `host\tuuid\tname` table of every session that has a display name +# set via `claude -n `. Used to enrich the resume picker so names show +# next to each row. +build_name_map() { + _py='import json, os, glob +for f in glob.glob(os.path.expanduser("~/.claude/sessions/*.json")): + try: d = json.load(open(f)) + except Exception: continue + sid = d.get("sessionId") or "" + name = d.get("name") or "" + if sid and name: print(f"{sid}\t{name}")' + scan_hosts | while IFS= read -r _h; do + if is_local "$_h"; then + python3 -c "$_py" 2>/dev/null + else + ssh -o BatchMode=yes -o ConnectTimeout=3 "$_h" "python3 -" 2>/dev/null <` label, stored in # ~/.claude/sessions/.json). Single ssh round-trip. Always included in # pattern searches because the file count is bounded (one per active pid). @@ -683,6 +705,21 @@ cmd_resume() { fi if [ "$_count" -gt 1 ]; then _keys="123456789abcdefghijklmnopqrstuvwxyz" + # Append a trailing name column (host+uuid → display name from + # ~/.claude/sessions/*.json). Empty for tmux rows and for sessions + # with no `claude -n` label. + _name_map=$(build_name_map) + _matches=$(printf '%s\n' "$_matches" | awk -F'\t' -v OFS='\t' -v map="$_name_map" ' + BEGIN { + n = split(map, lines, "\n") + for (i=1; i<=n; i++) { + split(lines[i], f, "\t") + if (f[1] && f[2]) names[f[1] SUBSEP f[2]] = f[3] + } + } + { nm = ($2=="tmux") ? "" : (($1 SUBSEP $3) in names ? names[$1 SUBSEP $3] : "") + print $0, nm } + ') if [ "$_count" -gt 35 ]; then _orig_count=$_count _matches=$(printf '%s\n' "$_matches" | head -n 35)