diff --git a/bin/rclaude b/bin/rclaude index 778dae1..1b780b1 100755 --- a/bin/rclaude +++ b/bin/rclaude @@ -1662,25 +1662,17 @@ inner=$(build_inner "$dir") # detached branch above; used by supervisor processes (e.g. clare web) # that bring up a remote Claude pane without attaching the calling tty. # -# We launch tmux inside a transient `systemd-run --user --unit=` -# user service rather than the calling ssh session's scope, with -# Restart=on-failure so a tmux server crash (heap-corruption bugs in -# older tmux builds, OOM-kill, etc.) is automatically recovered by -# systemd rather than waiting on Clare's 60s supervisor heartbeat. -# -# `--scope` was the old approach but a scope dies with its process — no -# restart. Falls back to a plain detached `tmux new-session -d` if the -# remote host has no systemd-run (e.g. macOS). +# Plain `ssh ... tmux new-session -d` — mirrors the attached remote path +# below (just `-d` instead of `-A`). A tmux server already survives ssh +# disconnect by design (that is what tmux is for); no cgroup gymnastics +# are needed. An earlier `systemd-run --user --scope --collect` wrapper +# here was a regression — `--collect` reaped the scope (and the tmux +# server inside its cgroup) the instant the spawning client exited, so +# the session never materialized. Verified 2026-05-20: plain ssh+tmux +# detached spawn survives; the systemd-run variant did not. # Mosh is interactive-only — always go through ssh for detached spawn. if [ -n "${RCLAUDE_DETACHED:-}" ]; then - # Run tmux inside a transient user scope so the tmux daemon escapes - # the calling ssh login session's cgroup (which systemd-logind would - # otherwise reap on disconnect, even with linger enabled). `--scope` - # exits as soon as the tmux daemon detaches; recovery from later - # tmux crashes is handled by Clare's supervisor heartbeat in - # `clare web` (re-runs ensure_running every 60s). - _remote_cmd="systemd-run --user --scope --collect --quiet tmux new-session -d -s '${session}' \"${inner}\" 2>/dev/null || tmux new-session -d -s '${session}' \"${inner}\"" - ssh $_SSH_LIVE_OPTS "$host" "$_remote_cmd" + ssh $_SSH_LIVE_OPTS "$host" "tmux new-session -d -s '${session}' \"${inner}\"" printf '%s\n' "$session" exit 0 fi