@@ -76,6 +76,10 @@ export class Remote {
7676 await this . closeRemote ( )
7777 return
7878 }
79+ // CLI versions before 2.3.3 don't support the --log-dir flag!
80+ // If this check didn't exist, VS Code connections would fail on
81+ // older versions because of an unknown CLI argument.
82+ const hasCoderLogs = ( parsedVersion ?. compare ( "2.3.3" ) || 0 ) >= 0 || parsedVersion ?. prerelease [ 0 ] === "devel"
7983
8084 // Find the workspace from the URI scheme provided!
8185 try {
@@ -426,14 +430,15 @@ export class Remote {
426430 //
427431 // If we didn't write to the SSH config file, connecting would fail with
428432 // "Host not found".
429- await this . updateSSHConfig ( authorityParts [ 1 ] )
433+ await this . updateSSHConfig ( authorityParts [ 1 ] , hasCoderLogs )
430434
431435 this . findSSHProcessID ( ) . then ( ( pid ) => {
432436 if ( ! pid ) {
433437 // TODO: Show an error here!
434438 return
435439 }
436440 disposables . push ( this . showNetworkUpdates ( pid ) )
441+ this . storage . workspaceLogPath = path . join ( this . storage . getLogPath ( ) , `${ pid } .log` )
437442 } )
438443
439444 // Register the label formatter again because SSH overrides it!
@@ -456,7 +461,7 @@ export class Remote {
456461
457462 // updateSSHConfig updates the SSH configuration with a wildcard that handles
458463 // all Coder entries.
459- private async updateSSHConfig ( hostName : string ) {
464+ private async updateSSHConfig ( hostName : string , hasCoderLogs = false ) {
460465 let deploymentSSHConfig = defaultSSHConfigResponse
461466 try {
462467 const deploymentConfig = await getDeploymentSSHConfig ( )
@@ -542,12 +547,16 @@ export class Remote {
542547 if ( typeof headerCommand === "string" && headerCommand . trim ( ) . length > 0 ) {
543548 headerArg = ` --header-command ${ escape ( headerCommand ) } `
544549 }
545-
550+ let logArg = ""
551+ if ( hasCoderLogs ) {
552+ await fs . mkdir ( this . storage . getLogPath ( ) , { recursive : true } )
553+ logArg = ` --log-dir ${ escape ( this . storage . getLogPath ( ) ) } `
554+ }
546555 const sshValues : SSHValues = {
547556 Host : `${ Remote . Prefix } *` ,
548557 ProxyCommand : `${ escape ( binaryPath ) } ${ headerArg } vscodessh --network-info-dir ${ escape (
549558 this . storage . getNetworkInfoPath ( ) ,
550- ) } --session-token-file ${ escape ( this . storage . getSessionTokenPath ( ) ) } --url-file ${ escape (
559+ ) } ${ logArg } --session-token-file ${ escape ( this . storage . getSessionTokenPath ( ) ) } --url-file ${ escape (
551560 this . storage . getURLPath ( ) ,
552561 ) } %h`,
553562 ConnectTimeout : "0" ,
0 commit comments