Skip to content

fix(desktop): switch a dead ssh -L forward to an SSH route on its own - #4204

Merged
LHagfoss merged 2 commits into
mainfrom
fix/desktop-forward-wake-reconnect
Nov 22, 2026
Merged

LHagfoss merged 2 commits into
mainfrom
fix/desktop-forward-wake-reconnect

Conversation

@LHagfoss

Copy link
Copy Markdown
Owner

What

Follow-up to #4163. With your own ssh -L (LagosVPS on 127.0.0.1:17880), the tunnel's link dies while the Mac sleeps. Until now the app only offered Let RustCode manage this tunnel. Nobody pressed it, so after every wake LagosVPS stayed offline for about a minute.

Now the machine supervisor (supervise in apps/desktop/src-tauri/src/machines.rs) does the takeover itself. The first time an attempt fails as unreachable, it checks the forward with stalled_forward. If that finds the running ssh -L (its owner) and no SSH route of RustCode's own is on, the supervisor:

  1. Tests an SSH route to that host.
  2. If the host answers, saves the route and turns the forwarded port off. This is the same code the button runs, moved into take_over_forward.
  3. Retries at once, skipping the backoff.

It tries this once per supervisor. If the host does not answer, the row keeps its advice and button, as before.

UX

Open the lid after a sleep. The first time, LagosVPS shows Connecting for a few seconds, then reconnects through an SSH route RustCode manages. After later wakes it reconnects within about 15 s, because every connection opens a fresh ssh -W. You don't need to press anything. Settings › Machines shows the SSH route as on and the forwarded port as off. Turning the forwarded port back on undoes it.

Changelog

A machine reached through your own ssh -L now switches to an SSH tunnel RustCode manages the first time that tunnel dies after a sleep, so it reconnects within seconds after later wakes.

Testing

cargo fmt --check. No local compile: this was written on the VPS, so CI builds and runs the checks.

After a wake a user-run ssh -L keeps its port open on a dead link, and the
machine stayed away until the user pressed 'Let RustCode manage this
tunnel'. The supervisor now does that takeover itself the first time it
finds the tunnel dead and the ssh -L behind it, then retries at once, so
later wakes reconnect through a fresh ssh -W within seconds.
@github-actions github-actions Bot added the fix A bug fix label Nov 22, 2026
@LHagfoss
LHagfoss merged commit 3797627 into main Nov 22, 2026
10 checks passed
@LHagfoss
LHagfoss deleted the fix/desktop-forward-wake-reconnect branch November 22, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants