Follow-ups from the session-recovery work (PR coming separately). Neither is needed today, but they would round out nssh sweep.
1. Auto-sweep on connect
Today nssh sweep <host> is a manual op. Once you trust the threshold, you almost never want to run it explicitly — you want it to happen as a side effect of nssh hostA.
Proposal: optional config key in ~/.config/nssh/config.toml:
sweep_older = "168h" # kill mosh-server processes older than this on connect
When set, every fresh nssh hostA (not a join) kicks off a background sweep matching the threshold after the interactive session starts, so the sweep doesn't block the user.
Open questions:
- Should it report what it killed on the next prompt, or stay silent?
- Skip the sweep if
--join / --replace / --new was passed explicitly?
- One global threshold or per-host?
2. Spare-yourself in --all
Today nssh sweep --all <host> would kill the mosh-server backing your current nssh session if you ran it from inside one. That's almost never what you want.
Proposal: capture the spawned mosh-server's remote PID at connect time, persist it in our local pidfile (~/.local/state/nssh/sessions/<pid>.json gets a new mosh_pid field), and --all excludes any PID we know is held by a live local nssh.
The fiddly part: mosh-client doesn't surface the remote mosh-server PID. Options:
- Right after
mosh hostA starts, do a side-channel ssh hostA pgrep -u \$USER -n mosh-server to find the youngest one. Race-prone but usually right.
- Have the remote shim write a breadcrumb at first invocation that includes
\$PPID (which is mosh-server). Reliable but happens lazily.
Either way, default behavior of nssh sweep (interactive) is unchanged — the user picks PIDs explicitly and knows which one is theirs.
Follow-ups from the session-recovery work (PR coming separately). Neither is needed today, but they would round out
nssh sweep.1. Auto-sweep on connect
Today
nssh sweep <host>is a manual op. Once you trust the threshold, you almost never want to run it explicitly — you want it to happen as a side effect ofnssh hostA.Proposal: optional config key in
~/.config/nssh/config.toml:When set, every fresh
nssh hostA(not a join) kicks off a background sweep matching the threshold after the interactive session starts, so the sweep doesn't block the user.Open questions:
--join/--replace/--newwas passed explicitly?2. Spare-yourself in
--allToday
nssh sweep --all <host>would kill the mosh-server backing your current nssh session if you ran it from inside one. That's almost never what you want.Proposal: capture the spawned mosh-server's remote PID at connect time, persist it in our local pidfile (
~/.local/state/nssh/sessions/<pid>.jsongets a newmosh_pidfield), and--allexcludes any PID we know is held by a live local nssh.The fiddly part:
mosh-clientdoesn't surface the remote mosh-server PID. Options:mosh hostAstarts, do a side-channelssh hostA pgrep -u \$USER -n mosh-serverto find the youngest one. Race-prone but usually right.\$PPID(which is mosh-server). Reliable but happens lazily.Either way, default behavior of
nssh sweep(interactive) is unchanged — the user picks PIDs explicitly and knows which one is theirs.