Skip to content

fix(remote): support Cursor's Remote-SSH port and label - #1244

Merged
EhabY merged 2 commits into
mainfrom
fix/cursor-remote-ssh-port-and-label
Dec 3, 2026
Merged

EhabY merged 2 commits into
mainfrom
fix/cursor-remote-ssh-port-and-label

Conversation

@EhabY

@EhabY EhabY commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1247.

Two fixes for Cursor with anysphere.remote-ssh 1.1.5 or later (checked against Cursor 3.32.25 and 1.1.19).

Find the SSH port in Cursor's Remote-SSH log. findPort looked for Socks port: <port>. Cursor's Remote-SSH stopped writing that in 1.1, so we never found the ssh process and the latency status bar item never showed up. Since 1.1 it logs the ssh command instead: Launching SSH server via shell with command: cat "<tmp>/cursor_remote_install_<uuid>.sh" | ssh ... -D <port> ..., or -L "127.0.0.1:<port>:<socket>" with the socket transport. findPort now reads that port. The match requires the cursor_remote_install_ script, which only the window's connection pipes in, so the manual connection report (which logs the same line with its own -D port) is ignored. The older Socks port: form and the other extensions' forms are unchanged. Each log line now has its own pattern in REMOTE_SSH_PORT_PATTERNS, and the match latest in the log still wins (same speed as the single regex: about 8ms for a 10 MB log).

Win the label formatter match in Cursor. VS Code uses the matching formatter with the longest authority pattern. Cursor registers <authority>*, which is one character longer than our exact <authority>, so Cursor showed SSH: <long host>. For ssh-remote+ windows we now register {<authority>}. It is a brace group with one choice, so it matches only this authority and is two characters longer. [ and ] are wrapped as [[]/[]]. Before this, IPv6 deployment hosts like [::1] were read as character classes and never matched in any editor. Nested dev container windows keep registering the exact authority, so their labels do not change.

Investigation notes

Port: Cursor's log lines with ssh arguments (anysphere.remote-ssh, all from execHandler)

Caller Prefix of the logged command Forwarding args
Window connection, Linux/macOS remote cat "<tmpdir>/cursor_remote_install_<uuid>.sh" | (type on a Windows client) -D <port>, or -L "127.0.0.1:<code>:<sock>" -L "127.0.0.1:<mux>:<sock>"
Window connection, Windows remote cat|type "<tmpdir>/cursor_remote_install_<uuid>.ps1" | -D <port>
Connection report command cat "<extensionPath>/dist/scripts/connectionReport.sh" | -D <port>
  • execHandler always logs Launching SSH server via shell with command:. Without the login terminal it then also logs Establishing SSH connection: with the same command. The report uses the same "Remote - SSH" output channel.
  • copyToRemote logs no ssh arguments. Matching only Launching ... with cursor_remote_install_ covers every connection path.
  • Release history, from downloaded builds:
    • 1.0.10 to 1.0.32 log [remote-ssh] Resolved exec server. Socks port: N and Resolved authority: {...}. Socks port: N. N is the same -D port, and these lines come after the command line.
    • 1.1.5, 1.1.10, 1.1.15 and 1.1.19 have no Socks port: and log the command line with cursor_remote_install_.
  • Who listens on the port: I ran Cursor's exact commands with spawn(cmd, {shell: true}) against a local sshd, with a ProxyCommand. In both transports, find("port", port) returned the ssh pid, not the sh wrapper, and the ProxyCommand's parent was that same pid.

Port: other extensions keep their current result

I built the test fixtures from each extension's real log templates. Each has a connection plus a reconnect, and in each the reconnect's port wins as before.

Extension Port lines Other lines checked for false matches
ms-vscode-remote.remote-ssh 0.129 Starting forwarding server. local port A -> socksPort B -> remotePort C, Spawned SSH tunnel between local port A and remote target ... Spawning tunnel with: ...
jeanp413.open-remote-ssh 0.6.2 Creating forwarding server A(local) => B(socks) => C(remote) Spawning ProxyCommand: ..., Spawned ssh server pid=...
windsurf-remote-openssh (Devin), antigravity-remote-openssh same (socks) form Launching SSH server with command: ssh -v -T -D N ... (no "via shell"), SSH askpass server listening on local port: N
anysphere.remote-ssh 1.0.x ... Socks port: N command lines (same port)
anysphere.remote-ssh 1.1+ command line -D N / first -L "127.0.0.1:N: connection report line

Label: formatters other extensions register

Extension authority
ms-vscode-remote.remote-ssh, windsurf-remote-openssh (Devin) <authority>
anysphere.remote-ssh 1.1.19 `${authority}*`
open-remote-ssh, antigravity-remote-openssh ssh-remote+*
ms-vscode-remote.remote-containers 0.487 <authority> (dynamic), dev-container+* / attached-container+* (package.json)
anysphere.remote-containers 1.0.42 `${authority}*`
Coder (this PR) {<authority>} for ssh-remote+..., <authority> for nested

Label: verification per IDE

For each IDE I extracted the bundled glob match that findFormatting calls from workbench.desktop.main.js using acorn and eslint-scope, with its dependencies, and ran it in Node. For VS Code itself I built src/vs/base/common/glob.ts from source with esbuild. The harness runs 348 checks, as both Linux and simulated Windows. All pass.

IDE Base findFormatting call Braces Result
VS Code main (911bb1f) 1.150 match(f.authority, a, {ignoreCase:true}) yes pass
VS Code 1.105.0 (engines min) 1.105 match(f.authority.toLowerCase(), a.toLowerCase()) yes pass
VSCodium 1.143.17232 1.143 match(..., {ignoreCase:true}) yes pass
Devin (windsurfVersion 3.16.11) 1.141.2 match(..., {ignoreCase:true}) yes pass
Antigravity IDE 2.9.0 1.107 match(..., {ignoreCase:true}) yes pass
Cursor 3.32.25 1.147 match(f.authority.toLowerCase(), a.toLowerCase()) yes pass

What the 348 checks cover:

  • Authorities: current, legacy (coder-vscode. in Cursor), mixed case, IPv6 ([::1], https_[2001:db8::1]_8443).
  • Matching: the exact authority matches, case-insensitively. X2, Xx, a prefix, xX and other hosts do not.
  • Winning: ours wins against Cursor's X*, ms-vscode-remote's exact X and ssh-remote+*, whether registered first or last. So re-registering is no longer needed for ordering, but it is harmless.
  • Upgrade with a cached memento: the cachedResourceLabelFormatters2 memento holds the old plain entry, the brace entry and Cursor's entry. Before our live registration, the cached brace entry wins. After it, our live one wins.
  • Nested dev-container+...@ssh-remote+...: against ms-containers' exact pattern and Cursor's *, in either order, the winner is the same as with today's plain pattern.
  • The bug: in every IDE the old plain form loses to Cursor's X*, and a plain IPv6 authority does not match itself.

Other places that read formatter.authority (same in all six bundles):

  • registerCachedFormatter dedupes by string equality. Our pattern is the same string for each authority, so dedupe still works.
  • $registerResourceLabelFormatter sets priority = true everywhere.
  • getHostLabel (remote indicator, window title) and getSeparator both go through findFormatting.
  • ${authority} in label templates is replaced with the resource's authority, not the formatter's.
  • The home formatters in main, VSCodium and Devin only apply to template formatters with home, which we do not register.
  • Every other x.authority === y.authority hit in the bundles is unrelated.

Label: characters an authority can contain

toRemoteAuthority and parseRemoteAuthority allow \w, -, ., +, @ (nested), and bracketed IPv6 labels. So { } , * ? \ cannot appear, but [ ] can. [ ] * ? are wrapped in a bracket class, which every glob above reads literally.

Generated by Coder Agents on behalf of @EhabY.

Comment thread src/remote/sshProcess.ts Resolved
EhabY added 2 commits December 3, 2026 15:19
Find the SSH port in anysphere.remote-ssh 1.1.5+ logs, ignoring its
connection report, and register the label formatter authority as a
one-choice brace group so it outranks Cursor's longer pattern.
@EhabY
EhabY force-pushed the fix/cursor-remote-ssh-port-and-label branch from facc340 to 7b96063 Compare December 3, 2026 15:19
@EhabY
EhabY requested a review from jeremyruppel December 3, 2026 15:21
@EhabY
EhabY merged commit 3e3638b into main Dec 3, 2026
20 checks passed
@EhabY
EhabY deleted the fix/cursor-remote-ssh-port-and-label branch December 3, 2026 15:27
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.

Cursor: SSH port not found and Coder workspace label not applied

2 participants