Skip to content

Commit 2770ea7

Browse files
committed
use cli version for featureset detection
1 parent 7e70e95 commit 2770ea7

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,5 +304,6 @@
304304
"semver": "7.6.2",
305305
"trim": "0.0.3",
306306
"word-wrap": "1.2.5"
307-
}
307+
},
308+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
308309
}

src/remote.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as semver from "semver"
1212
import * as vscode from "vscode"
1313
import { makeCoderSdk, startWorkspace, waitForBuild } from "./api"
1414
import { extractAgents } from "./api-helper"
15+
import * as cli from "./cliManager"
1516
import { Commands } from "./commands"
1617
import { getHeaderCommand } from "./headers"
1718
import { SSHConfig, SSHValues, mergeSSHConfigValues } from "./sshConfig"
@@ -541,11 +542,28 @@ export class Remote {
541542
}
542543
}
543544

545+
/**
546+
* Tries to get the install CLI version. If that fails, defaults
547+
* to the remote coder version. For the most part these should be in sync.
548+
*/
549+
private async probableCoderVersion(binaryPath: string): Promise<semver.SemVer | null> {
550+
try {
551+
const version = await cli.version(binaryPath)
552+
const parsedVersion = semver.parse(version)
553+
if (!parsedVersion) {
554+
return this.coderVersion
555+
}
556+
return parsedVersion
557+
} catch (e) {
558+
return this.coderVersion
559+
}
560+
}
561+
544562
/**
545563
* Format's the --log-dir argument for the ProxyCommand
546564
*/
547-
private async formatLogArg(): Promise<string> {
548-
if (!supportsCoderAgentLogDirFlag(this.coderVersion)) {
565+
private async formatLogArg(binpath: string): Promise<string> {
566+
if (!supportsCoderAgentLogDirFlag(await this.probableCoderVersion(binpath))) {
549567
return ""
550568
}
551569

@@ -659,7 +677,7 @@ export class Remote {
659677
Host: label ? `${AuthorityPrefix}.${label}--*` : `${AuthorityPrefix}--*`,
660678
ProxyCommand: `${escape(binaryPath)}${headerArg} vscodessh --network-info-dir ${escape(
661679
this.storage.getNetworkInfoPath(),
662-
)}${await this.formatLogArg()} --session-token-file ${escape(this.storage.getSessionTokenPath(label))} --url-file ${escape(
680+
)}${await this.formatLogArg(binaryPath)} --session-token-file ${escape(this.storage.getSessionTokenPath(label))} --url-file ${escape(
663681
this.storage.getUrlPath(label),
664682
)} %h`,
665683
ConnectTimeout: "0",

0 commit comments

Comments
 (0)