Repository navigation
fix(remote): support Cursor's Remote-SSH port and label - #1244
Merged
Merged
Conversation
jeremyruppel
reviewed
Dec 3, 2026
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
force-pushed
the
fix/cursor-remote-ssh-port-and-label
branch
from
December 3, 2026 15:19
facc340 to
7b96063
Compare
jeremyruppel
approved these changes
Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1247.
Two fixes for Cursor with
anysphere.remote-ssh1.1.5 or later (checked against Cursor 3.32.25 and 1.1.19).Find the SSH port in Cursor's Remote-SSH log.
findPortlooked forSocks 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 thecursor_remote_install_script, which only the window's connection pipes in, so the manual connection report (which logs the same line with its own-Dport) is ignored. The olderSocks port:form and the other extensions' forms are unchanged. Each log line now has its own pattern inREMOTE_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
authoritypattern. Cursor registers<authority>*, which is one character longer than our exact<authority>, so Cursor showedSSH: <long host>. Forssh-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 fromexecHandler)cat "<tmpdir>/cursor_remote_install_<uuid>.sh" |(typeon a Windows client)-D <port>, or-L "127.0.0.1:<code>:<sock>" -L "127.0.0.1:<mux>:<sock>"cat|type "<tmpdir>/cursor_remote_install_<uuid>.ps1" |-D <port>cat "<extensionPath>/dist/scripts/connectionReport.sh" |-D <port>execHandleralways logsLaunching SSH server via shell with command:. Without the login terminal it then also logsEstablishing SSH connection:with the same command. The report uses the same "Remote - SSH" output channel.copyToRemotelogs no ssh arguments. Matching onlyLaunching ...withcursor_remote_install_covers every connection path.[remote-ssh] Resolved exec server. Socks port: NandResolved authority: {...}. Socks port: N. N is the same-Dport, and these lines come after the command line.Socks port:and log the command line withcursor_remote_install_.spawn(cmd, {shell: true})against a local sshd, with a ProxyCommand. In both transports,find("port", port)returned thesshpid, not theshwrapper, 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.
Starting forwarding server. local port A -> socksPort B -> remotePort C,Spawned SSH tunnel between local port A and remote target ...Spawning tunnel with: ...Creating forwarding server A(local) => B(socks) => C(remote)Spawning ProxyCommand: ...,Spawned ssh server pid=...(socks)formLaunching SSH server with command: ssh -v -T -D N ...(no "via shell"),SSH askpass server listening on local port: N... Socks port: N-D N/ first-L "127.0.0.1:N:Label: formatters other extensions register
authority<authority>`${authority}*`ssh-remote+*<authority>(dynamic),dev-container+*/attached-container+*(package.json)`${authority}*`{<authority>}forssh-remote+...,<authority>for nestedLabel: verification per IDE
For each IDE I extracted the bundled glob
matchthatfindFormattingcalls fromworkbench.desktop.main.jsusing acorn and eslint-scope, with its dependencies, and ran it in Node. For VS Code itself I builtsrc/vs/base/common/glob.tsfrom source with esbuild. The harness runs 348 checks, as both Linux and simulated Windows. All pass.findFormattingcall911bb1f)match(f.authority, a, {ignoreCase:true})match(f.authority.toLowerCase(), a.toLowerCase())match(..., {ignoreCase:true})match(..., {ignoreCase:true})match(..., {ignoreCase:true})match(f.authority.toLowerCase(), a.toLowerCase())What the 348 checks cover:
coder-vscode.in Cursor), mixed case, IPv6 ([::1],https_[2001:db8::1]_8443).X2,Xx, a prefix,xXand other hosts do not.X*, ms-vscode-remote's exactXandssh-remote+*, whether registered first or last. So re-registering is no longer needed for ordering, but it is harmless.cachedResourceLabelFormatters2memento 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.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.X*, and a plain IPv6 authority does not match itself.Other places that read
formatter.authority(same in all six bundles):registerCachedFormatterdedupes by string equality. Our pattern is the same string for each authority, so dedupe still works.$registerResourceLabelFormattersetspriority = trueeverywhere.getHostLabel(remote indicator, window title) andgetSeparatorboth go throughfindFormatting.${authority}in label templates is replaced with the resource's authority, not the formatter's.home, which we do not register.x.authority === y.authorityhit in the bundles is unrelated.Label: characters an authority can contain
toRemoteAuthorityandparseRemoteAuthorityallow\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.