Skip to content

fix(attach,doctor): dial the configured ssh_port; name the port on doctor timeouts - #180

Merged
skzv merged 1 commit into
mainfrom
claude/fix-remoteattach-port
Aug 5, 2026
Merged

fix(attach,doctor): dial the configured ssh_port; name the port on doctor timeouts#180
skzv merged 1 commit into
mainfrom
claude/fix-remoteattach-port

Conversation

@skzv

@skzv skzv commented Aug 5, 2026

Copy link
Copy Markdown
Owner

The two follow-ups left over from the review sweep, both with fail-before-verified tests.

1. The attach path ignored ssh_port

#174 threaded SSHPort through the TUI's create-session forms, but every argv builder in internal/remoteattach dropped it. The result: ccmux created a session on a custom-port host correctly, then dialed port 22 to attach to it — leaving the user stranded with a session they couldn't reach. The same drop hit the Network screen's shell action and both the discovered-peer and configured-host attach paths.

Fail-before output is exactly the reported symptom:

attach argv [ssh -t sasha@mini PATH=... tmux attach-session -t 'c-x'] missing "-p 2222"

Port is now a required parameter on SSH/SSHInteractive/Mosh/RunArgv rather than a separate *Port variant. That's deliberate: the old shape had precisely that split — SSHInteractivePort existed while call sites reached for the port-blind SSHInteractive — which is how the bug survived. Making it required means a new call site has to make a decision. Passing 0 or 22 produces argv byte-identical to before (pinned by a test).

The mosh trap gets its own test. mosh's own -p is the UDP port range for the mosh session, not the SSH port — passing it the way ssh takes it would request a UDP bind on 2222 while still connecting to SSH on 22. The port has to travel via --ssh=ssh -p N. The test asserts both that --ssh is present and that no bare -p appears.

2. doctor's timeout branch hid the port

The refused and OK branches both named the probed port; timeout didn't. So on a custom-port host, the one case where "did we probe the wrong port?" is the live question was the case that stayed silent about it.

Extracted the branch copy into probeResultLine so every message is testable without a live host, and pinned the rule: any branch whose cause could be a wrong port must name it — while ProbeNoNetwork deliberately does not, since name resolution failed before anything was dialed.

Verification

  • Fail-before confirmed for both fixes by reverting each.
  • New: TestSSH_CustomPortAddsFlag, TestDefaultPorts_ArgvUnchanged, TestMosh_CustomPortUsesSSHFlagNotDashP, TestRunArgv_PortPerBinary, TestRemoteNewSessionAttach_DialsConfiguredPort, TestRemoteNewSessionAttach_DefaultPortUnchanged, and three probeResultLine tests.
  • Full go test ./... green; e2e doctor tests green (they assert on these strings); linux + windows cross-compile clean.

🤖 Generated with Claude Code

…ctor timeouts

Two follow-ups from the review sweep.

1. remoteattach dropped the SSH port. #174 threaded SSHPort through the
   TUI's create-session forms, but every argv builder here ignored it,
   so ccmux created a session on a custom-port host and then dialed 22
   to attach — stranding the user with a session they couldn't reach.
   The same drop hit the Network screen's shell action and both
   discovered-peer and configured-host attach paths.

   Port is now a required parameter on SSH/SSHInteractive/Mosh/RunArgv
   rather than a separate *Port variant. The old shape had exactly that
   split — SSHInteractivePort existed while callers reached for the
   port-blind SSHInteractive — which is how the bug survived. Making it
   required means a new call site has to decide. 0 and 22 produce argv
   byte-identical to before.

   mosh needs different syntax and that trap gets its own test: mosh's
   -p is the UDP port range for the mosh session, NOT the ssh port, so
   passing it the way ssh takes it would request a UDP bind on 2222
   while still connecting to SSH on 22. The port travels via --ssh.

2. doctor's timeout branch didn't name the port while refused/OK both
   did — so the one case where 'did we probe the wrong port?' is the
   live question was the case that stayed silent. Extracted the branch
   copy into probeResultLine so every message is testable without a
   live host, and pinned the rule.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@skzv
skzv merged commit f9e1e1a into main Aug 5, 2026
6 checks passed
@skzv
skzv deleted the claude/fix-remoteattach-port branch August 5, 2026 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant