fix(remote-ssh): use remote user's real shell, keep dead panes alive

Remote shell-mode sessions hardcoded 'exec bash -l', ignoring the
remote user's actual login shell. sshd sets $SHELL from the remote
user's /etc/passwd entry, so 'exec $SHELL -i -l' launches their real
shell (zsh, fish, etc.) with rc files sourced, same fix as the local
shell-mode launch.

Also set remain-on-exit on the remote tmux session. It was only ever
set on the local socket, so if the remote command exited for any
reason -- even something transient -- tmux destroyed the pane, window,
and (being the only session) the whole remote server, tearing down the
local ssh attach along with it and leaving no trace to diagnose. The
local pane saw this as an instant clean exit, and reconnect's -A then
created a fresh session, which could repeat as a flap loop with no
evidence surviving between attempts.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
timkjr
2026-08-04 16:39:29 -05:00
co-authored by Claude Sonnet 5
parent 529d8fa8ea
commit 474efd9023
5 changed files with 18 additions and 4 deletions
+5 -1
View File
@@ -60,7 +60,11 @@ export async function writeRemoteCases(configDir: string, cases: RemoteCase[]):
export function defaultRemoteCommandForMode(mode: SessionMode): string {
const commands: Record<RemoteCommandMode, string> = {
shell: 'exec bash -l',
// $SHELL, not a hardcoded bash: sshd sets it from the remote user's
// /etc/passwd entry, so this launches their actual login shell (zsh,
// fish, etc.). -i -l so it sources rc files (~/.zshrc etc.), matching
// the local shell-mode launch.
shell: 'exec $SHELL -i -l',
// Mirror the LOCAL claude default so the remote agent runs non-interactively
// (no trust-folder/permission prompt that nothing on the remote answers). The
// per-host `commands.claude` override stays the escape hatch.
+8
View File
@@ -873,6 +873,14 @@ export function buildRemoteLaunchCommand(options: {
// shared remote tmux server's other sessions keep their own prefix/mouse.
const tmuxInvocation = [
`tmux -L ${REMOTE_TMUX_SOCKET} new-session -A -s ${remoteName} -c ${shellescape(remote.remotePath)} ${shellescape(paneCommand)}`,
// Without this, tmux's default behavior destroys the pane -> window ->
// session (and, being the only session, the whole remote server) the
// instant paneCommand exits for ANY reason -- even something transient.
// That tears down the local ssh -t attach along with it (dead pane,
// status whatever ssh reported), and reconnect's `-A` then creates a
// fresh session with no trace of what actually happened. Set first, so
// it applies as early as possible after the pane starts.
`set -t ${remoteName} remain-on-exit on`,
`set -t ${remoteName} status off`,
`set -t ${remoteName} mouse off`,
`set -t ${remoteName} prefix C-q`,