Commit c78d077
nssh: harden session recovery
- skip prepareRemote when joining an existing session for the host
(the original process already wrote the remote session file and
seeded the log; redoing it costs an SSH and adds a misleading
duplicate session-open event)
- record `joined: <pid>` on the local session-start event so the log
distinguishes a fresh connect from a join
subscriber resilience:
- log subscribe-up / subscribe-down events with reconnect gap, so
silent failures are visible in `nssh status --tail`
- track the most-recent ntfy message id and pass it as ?since=<id>
on every reconnect — anything posted while we were asleep / on a
broken connection is replayed instead of dropped on the floor
liveness + collision UX:
- new ping / pong wire kinds and a pingTopic helper (one-shot
subscribe + publish + wait for ack) to distinguish "PID is alive
and answering" from "PID is alive but wedged"
- on a session collision, ping the existing peer and prompt
interactively: [J]oin / [R]eplace (SIGTERM + escalate to SIGKILL)
/ [N]ew topic / [C]ancel. Default is join when alive, replace
when not. Non-interactive shells silently join with a stderr
warning if the peer didn't answer.
- new flags --join / --replace / --new to skip the prompt
remote cleanup:
- new `nssh sweep [--all|--older <dur>] <host>` subcommand that
enumerates mosh-server processes owned by $USER on the remote
and offers to kill them. Safe with tmux-inside-mosh: tmux server
is its own daemon, so detached sessions survive.
follow-ups in #10 (auto-sweep on connect, spare-yourself in --all).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 7af523b commit c78d077
6 files changed
Lines changed: 636 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
44 | 50 | | |
45 | 51 | | |
46 | 52 | | |
| |||
82 | 88 | | |
83 | 89 | | |
84 | 90 | | |
| 91 | + | |
| 92 | + | |
85 | 93 | | |
86 | 94 | | |
87 | 95 | | |
| |||
93 | 101 | | |
94 | 102 | | |
95 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
96 | 122 | | |
97 | 123 | | |
98 | 124 | | |
| |||
0 commit comments