rclaude: pre-flight remote dir existence; loud error instead of silent ssh-close
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 <host> closed.'
This commit is contained in:
parent
47434868e0
commit
77cd1c74b1
1 changed files with 19 additions and 1 deletions
20
bin/rclaude
20
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/<bucket>/<project> mapping." >&2
|
||||
;;
|
||||
esac
|
||||
exit 1
|
||||
fi
|
||||
|
||||
inner="cd ${dir} && exec claude --continue ${flag}"
|
||||
exec ssh -t "$host" "tmux new-session -A -s '${session}' \"${inner}\""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue