File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import * as vscode from "vscode";
12
12
import * as ws from "ws" ;
13
13
import { errToStr } from "./api-helper" ;
14
14
import { CertificateError } from "./error" ;
15
+ import { FeatureSet } from "./featureSet" ;
15
16
import { getHeaderArgs } from "./headers" ;
16
17
import { getProxyForUrl } from "./proxy" ;
17
18
import { Storage } from "./storage" ;
@@ -174,6 +175,7 @@ export async function startWorkspaceIfStoppedOrFailed(
174
175
binPath : string ,
175
176
workspace : Workspace ,
176
177
writeEmitter : vscode . EventEmitter < string > ,
178
+ featureSet : FeatureSet ,
177
179
) : Promise < Workspace > {
178
180
// Before we start a workspace, we make an initial request to check it's not already started
179
181
const updatedWorkspace = await restClient . getWorkspace ( workspace . id ) ;
@@ -191,6 +193,10 @@ export async function startWorkspaceIfStoppedOrFailed(
191
193
"--yes" ,
192
194
workspace . owner_name + "/" + workspace . name ,
193
195
] ;
196
+ if ( featureSet . buildReason ) {
197
+ startArgs . push ( ...[ "--reason" , "vscode_connection" ] ) ;
198
+ }
199
+
194
200
const startProcess = spawn ( binPath , startArgs ) ;
195
201
196
202
startProcess . stdout . on ( "data" , ( data : Buffer ) => {
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ export type FeatureSet = {
4
4
vscodessh : boolean ;
5
5
proxyLogDirectory : boolean ;
6
6
wildcardSSH : boolean ;
7
+ buildReason : boolean ;
7
8
} ;
8
9
9
10
/**
@@ -29,5 +30,10 @@ export function featureSetForVersion(
29
30
wildcardSSH :
30
31
( version ? version . compare ( "2.19.0" ) : - 1 ) >= 0 ||
31
32
version ?. prerelease [ 0 ] === "devel" ,
33
+
34
+ // The --reason flag was added to `coder start` in 2.25.0
35
+ buildReason :
36
+ ( version ?. compare ( "2.25.0" ) || 0 ) >= 0 ||
37
+ version ?. prerelease [ 0 ] === "devel" ,
32
38
} ;
33
39
}
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ export class Remote {
68
68
workspace : Workspace ,
69
69
label : string ,
70
70
binPath : string ,
71
+ featureSet : FeatureSet ,
71
72
) : Promise < Workspace | undefined > {
72
73
const workspaceName = `${ workspace . owner_name } /${ workspace . name } ` ;
73
74
@@ -136,6 +137,7 @@ export class Remote {
136
137
binPath ,
137
138
workspace ,
138
139
writeEmitter ,
140
+ featureSet ,
139
141
) ;
140
142
break ;
141
143
case "failed" :
@@ -153,6 +155,7 @@ export class Remote {
153
155
binPath ,
154
156
workspace ,
155
157
writeEmitter ,
158
+ featureSet ,
156
159
) ;
157
160
break ;
158
161
}
@@ -383,6 +386,7 @@ export class Remote {
383
386
workspace ,
384
387
parts . label ,
385
388
binaryPath ,
389
+ featureSet ,
386
390
) ;
387
391
if ( ! updatedWorkspace ) {
388
392
// User declined to start the workspace.
You can’t perform that action at this time.
0 commit comments