feat(@scripts/session-tools): ✨ add resume display name restoration
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
6e67a5aa57
commit
2b3c95d3f2
1 changed files with 16 additions and 1 deletions
17
bin/rclaude
17
bin/rclaude
|
|
@ -1239,6 +1239,21 @@ build_inner() {
|
|||
elif [ "${RCLAUDE_RESUME:-0}" = "1" ]; then
|
||||
_resume_flag="--continue"
|
||||
fi
|
||||
# Auto-restore display name on resume. Claude's `name` field lives in
|
||||
# ~/.claude/sessions/<pid>.json — wiped on every restart/resume — so if
|
||||
# we know a uuid had a name previously (from the durable index), pass
|
||||
# it back via `claude -n <name>` so the resumed pid is re-labeled.
|
||||
# Explicit RCLAUDE_RESUME_NAME overrides any index lookup.
|
||||
_name_flag=""
|
||||
_name_val=${RCLAUDE_RESUME_NAME:-}
|
||||
if [ -z "$_name_val" ] && [ -n "${RCLAUDE_RESUME_ID:-}" ] && [ -s "${_NAME_INDEX:-}" ]; then
|
||||
_name_val=$(awk -F'\t' -v u="$RCLAUDE_RESUME_ID" '$2 == u { print $3; exit }' "$_NAME_INDEX" 2>/dev/null)
|
||||
fi
|
||||
if [ -n "$_name_val" ]; then
|
||||
# Escape single quotes for safe shell embedding.
|
||||
_name_esc=$(printf %s "$_name_val" | sed "s/'/'\\\\''/g")
|
||||
_name_flag="-n '${_name_esc}'"
|
||||
fi
|
||||
# When launching on a remote host, tell its MCPs where to forward
|
||||
# audio back to (so apricot's TTS plays on the local Mac, etc.). When
|
||||
# local, leave the env alone — local MCPs play locally.
|
||||
|
|
@ -1248,7 +1263,7 @@ build_inner() {
|
|||
_back_env="export SPEECH_PLAYBACK_HOST=${_back}; "
|
||||
fi
|
||||
printf '%s' \
|
||||
"${_back_env}cd ${1} && rc_t=\$(date +%s); claude ${_resume_flag} ${flag}; rc_ec=\$?; " \
|
||||
"${_back_env}cd ${1} && rc_t=\$(date +%s); claude ${_resume_flag} ${_name_flag} ${flag}; rc_ec=\$?; " \
|
||||
"rc_e=\$(date +%s); rc_d=\$((rc_e - rc_t)); " \
|
||||
"if [ \$rc_ec -ne 0 ] || [ \$rc_d -lt 2 ]; then " \
|
||||
"printf '\\n[rclaude] claude exited in %ds with code %d\\n' \$rc_d \$rc_ec; " \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue