From 77cd1c74b1d61a9c5e67a2be9c6e10aa400d634a Mon Sep 17 00:00:00 2001 From: Natalie Date: Sun, 26 Apr 2026 00:10:02 -0700 Subject: [PATCH] rclaude: pre-flight remote dir existence; loud error instead of silent ssh-close MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Catches typos and Claude-instruction-style aliases (@proj/@apps/@pkg) that look like paths but only resolve in the assistant's mental model, not in any shell. Without the check the cd inside the tmux command failed silently, the pane died, the session closed, ssh exited — surfaced to the user as a bare 'Connection to closed.' --- bin/rclaude | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/bin/rclaude b/bin/rclaude index 375b63d..0bc63ad 100755 --- a/bin/rclaude +++ b/bin/rclaude @@ -212,9 +212,27 @@ if is_local "$host"; then echo "rclaude: tmux not installed locally — install via 'brew install tmux' (macOS) or your package manager" >&2 exit 1 fi - cd "$dir" + if ! cd "$dir" 2>/dev/null; then + echo "rclaude: local directory not found: $dir" >&2 + exit 1 + fi exec tmux new-session -A -s "$session" "exec claude --continue ${flag}" fi +# Remote: pre-flight the directory on the remote host so a typo or missing +# path fails loudly here instead of silently killing the tmux pane and +# closing the ssh transport (which looks like a generic "connection closed" +# error to the user). +if ! ssh -o BatchMode=yes -o ConnectTimeout=5 "$host" "test -d ${dir}" 2>/dev/null; then + echo "rclaude: directory not found on $host: $dir" >&2 + case $dir in + *@proj/*|*@apps/*|*@pkg/*) + echo " hint: '@proj/@apps/@pkg' are Claude-instruction aliases, not real shell paths." >&2 + echo " See ~/.claude/instructions/project-paths.md for the real ~/Code// mapping." >&2 + ;; + esac + exit 1 +fi + inner="cd ${dir} && exec claude --continue ${flag}" exec ssh -t "$host" "tmux new-session -A -s '${session}' \"${inner}\""