feat(@scripts): add unique timestamp to tmux session names

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Natalie 2026-04-26 15:47:26 -07:00
parent 4b63a48d05
commit 9888fb1a31

View file

@ -6,9 +6,10 @@
# 2. `claude --continue` resumes the per-directory session from disk after
# the host itself dies (reboot, crash, OOM).
#
# Re-running with the same target lands you back in the same conversation:
# tmux reattaches if alive; claude --continue picks up from
# ~/.claude/projects/<encoded-cwd>/ otherwise.
# Each invocation starts a fresh Claude session in a new named tmux window.
# To reattach an existing session: `rclaude resume [pattern]`
# To resume a Claude conversation from disk after host loss: `rclaude resume` picks
# up the on-disk session via `claude --continue`.
#
# Permission mode: --dangerously-skip-permissions is on by default. Override
# with RCLAUDE_PERMS=default (or any --permission-mode value).
@ -218,7 +219,7 @@ fi
slug=$(printf %s "$dir" | sed -e 's|^[~/]*||' -e 's|[^A-Za-z0-9]|-|g')
[ -z "$slug" ] && slug=home
session="claude-$(whoami)-${slug}"
session="claude-$(whoami)-${slug}-$(date +%s)"
perms=${RCLAUDE_PERMS:-bypass}
case $perms in
@ -236,10 +237,9 @@ build_inner() {
# Single-line, single-quote-safe. Variables prefixed with rc_ to avoid
# collision with anything in the user's shell.
#
# Note: launch path uses plain `claude` (fresh session). Reattach to a
# live conversation is handled by tmux (named session keyed on dir, so
# re-running rclaude in the same dir reattaches). Disk-resume is the
# explicit `rclaude resume <pattern>` subcommand.
# Note: launch path uses plain `claude` (fresh session). Each invocation
# creates a new uniquely-named tmux session. Reattach to a live session
# via `rclaude resume <pattern>`; disk-resume after host death likewise.
_resume_flag=""
[ "${RCLAUDE_RESUME:-0}" = "1" ] && _resume_flag="--continue"
printf '%s' \
@ -260,7 +260,7 @@ if is_local "$host"; then
echo "rclaude: local directory not found: $dir" >&2
exit 1
fi
exec tmux new-session -A -s "$session" "$(build_inner "$dir")"
exec tmux new-session -s "$session" "$(build_inner "$dir")"
fi
# Remote: pre-flight the directory so a typo or missing path fails loudly
@ -278,4 +278,4 @@ if ! ssh -o BatchMode=yes -o ConnectTimeout=5 "$host" "test -d ${dir}" 2>/dev/nu
fi
inner=$(build_inner "$dir")
exec ssh -t "$host" "tmux new-session -A -s '${session}' \"${inner}\""
exec ssh -t "$host" "tmux new-session -s '${session}' \"${inner}\""