#4797·herdr

A new selection closes an SSH machine's connection before its timeout while a switch is being cancelled

Author: mikirejfCreated Sep 30, 2026Updated Sep 30, 2026
Labelsbugmaintainer-neededp2remotetriaged

Is this a reproducible bug?

  • I confirm this is a reproducible bug, not a feature request, idea, question, contribution proposal, or direction check.
  • I reproduced this bug on the version and environment reported below using the exact steps provided.

I confirmed it with a client unit test on v0.9.3, shown below. I did not click through the steps live, because I have only one saved machine.

Current behavior

I start on a Local workspace and select a workspace on SSH machine A. Before A answers, I select a workspace on SSH machine B, so herdr starts cancelling the switch to A. If I then select any remote workspace before A confirms the cancel, herdr closes A's connection at once. It does not wait for A's 5 second timeout. A then reconnects with backoff.

Expected behavior

The later selection only changes where herdr goes next. A's connection stays open until A confirms the cancel or the timeout passes. Herdr already does this when the later selection arrives while it restores the previous workspace.

Reproduction

Steps, not run live:

  1. Save two SSH machines, A and B, and add about 1 s of delay to A's link.
  2. Start on a Local workspace.
  3. Select a workspace on A. Within 1 s, select one on B. Within another 1 s, select any workspace on A or B.
  4. A goes to Reconnecting.

The same sequence as a test for src/client/endpoint/activation_tests.rs. On v0.9.3 it fails at the connection(&target).is_some() assertion:

rust
#[test]
fn a_newer_intent_does_not_close_an_unexpired_target_revocation() {
    let (shell, mut endpoints, _local_sent, _remote_sent) = shell_and_registry();
    let target = endpoint();
    let other = ClientEndpointId::Ssh(
        super::super::ProfileId::parse("fedcba9876543210fedcba9876543210").unwrap(),
    );
    let mut activation = PendingEndpointActivation::begin(
        &shell, &mut endpoints, target.clone(), None, resize(), 90, Instant::now(),
    )
    .unwrap();
    let _ = activation.receive_response(
        &ClientEndpointId::Local,
        1,
        "client-shell-surface:90:off",
        &surface_success("client-shell-surface:90:off", false, 1),
        &mut endpoints,
    );
    assert!(matches!(activation.phase, ActivationPhase::ActivatingTarget { .. }));
    assert_eq!(activation.supersede(other, None, &mut endpoints), ActivationRollback::Pending);
    assert!(matches!(activation.phase, ActivationPhase::ReleasingTargetForRollback { .. }));
    assert!(!activation.expired(Instant::now()));

    assert_eq!(
        activation.supersede(target.clone(), None, &mut endpoints),
        ActivationRollback::Pending
    );
    assert!(
        endpoints.connection(&target).is_some(),
        "a newer selection must not close a connection before its timeout"
    );
}

Impact

My remote is a Linux box reached over Tailscale, with about 70 ms round trips and bursts of packet loss. On that link a switch to the remote sometimes waits several seconds. Clicking again during that wait can turn the delay into a disconnect plus reconnect backoff.

Environment

  • Herdr 0.9.3, stable channel
  • Client: macOS 15.6.1, Ghostty 1.3.1
  • Remote: Ubuntu 24.04.5 LTS over SSH through Tailscale