Fix remote file explorer over proxied SSH hosts (ControlMaster reuse)

Merged
NK
1mo ago
+129-28

Summary

On a cmux ssh workspace reached through a slow ProxyCommand, such as a Coder *.coder host, the Files sidebar shows "SSH command failed" and remote git status stays empty while the terminal works. Both run background ssh with the workspace's options, which include ControlMaster=auto and ControlPersist=600, so every listing, home lookup, preview and git status run tries to become its own master and negotiates a new connection through the proxy. ConnectTimeout=5 runs out first.

ProcessSSHFileExplorerTransport.sshArguments now builds its argv with WorkspaceRemoteConfiguration.batchSSHCommandArguments, the builder the daemon, relay and control-master reap runs already use, and GitStatusProvider calls the same function. Probes keep the workspace's ControlPath and reuse the terminal's master, but pass ControlMaster=no and drop ControlMaster/ControlPersist, so they never become one. They also get the rest of that batch policy: ConnectTimeout=6, keepalives, StrictHostKeyChecking=accept-new unless configured, and BatchMode=yes ahead of the workspace options, since OpenSSH keeps the first value it reads. Because a probe can no longer become the master that interactive sessions multiplex over, it turns off agent, X11 and port forwarding like the other batch runs, which replaces the "Forwarding stays as configured" caveat at both call sites.

This PR was rebuilt on current main and narrowed. The remote-root change it used to carry is covered by #7277 (trustedRemoteCurrentDirectory), and the sanitized SSH error messages will come in a separate PR.

Testing

cmuxTests/FileExplorerSSHMasterReuseTests (new) resolves each probe's argv with ssh -G -F /dev/null and expects controlmaster false, controlpersist no and the workspace ControlPath. One test calls the explorer's builder; the other captures the argv GitStatusProvider.fetchStatusSSH hands to a fake ssh.

There's no Xcode on the machine I used, so these haven't run in the cmuxTests target yet. For red/green evidence, a scratch SwiftPM package compiled the real Sources/GitStatusProvider.swift and Sources/GitFileStatus.swift, plus SSHFileExplorerConnection and sshArguments copied verbatim from Sources/FileExplorerStore.swift, against the repo's CmuxCore and CmuxFoundation packages, and ran the new test file and FileExplorerGitStatusProviderTests unchanged with swift test:

  • 5d40c16 (test only): both new tests fail with controlmaster auto and controlpersist 600; the 6 existing git status tests pass.
  • 3e363d2 (fix): all 8 tests pass, including sshStatusQueryOverridesHostConfiguredRemoteCommand.

python3 scripts/verify-local.py passed its 16 selected static checks. Still unverified: the app build, the cmuxTests run in CI, and a live check against a Coder workspace on this rebuilt branch (the June version of the fix was checked against one).

Changelog

Fixed: The Files sidebar and git status now load on cmux ssh workspaces reached through a slow ProxyCommand, such as Coder hosts.

Checklist

  • Behavior changes have added or updated tests, or Testing says why not
  • Reviewed with a subagent before merge (cmux-review), and all bot and human review comments resolved

Summary by CodeRabbit

  • Bug Fixes
    • File explorer and Git status SSH connections now use the workspace’s configured connection settings, including its shared connection path, without enabling separate connection persistence.
  • Tests
    • Added coverage verifying that both features respect the workspace’s SSH configuration.