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";
1212import * as ws from "ws" ;
1313import { errToStr } from "./api-helper" ;
1414import { CertificateError } from "./error" ;
15+ import { FeatureSet } from "./featureSet" ;
1516import { getHeaderArgs } from "./headers" ;
1617import { getProxyForUrl } from "./proxy" ;
1718import { Storage } from "./storage" ;
@@ -174,6 +175,7 @@ export async function startWorkspaceIfStoppedOrFailed(
174175 binPath : string ,
175176 workspace : Workspace ,
176177 writeEmitter : vscode . EventEmitter < string > ,
178+ featureSet : FeatureSet ,
177179) : Promise < Workspace > {
178180 // Before we start a workspace, we make an initial request to check it's not already started
179181 const updatedWorkspace = await restClient . getWorkspace ( workspace . id ) ;
@@ -191,6 +193,10 @@ export async function startWorkspaceIfStoppedOrFailed(
191193 "--yes" ,
192194 workspace . owner_name + "/" + workspace . name ,
193195 ] ;
196+ if ( featureSet . buildReason ) {
197+ startArgs . push ( ...[ "--reason" , "vscode_connection" ] ) ;
198+ }
199+
194200 const startProcess = spawn ( binPath , startArgs ) ;
195201
196202 startProcess . stdout . on ( "data" , ( data : Buffer ) => {
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ export type FeatureSet = {
44 vscodessh : boolean ;
55 proxyLogDirectory : boolean ;
66 wildcardSSH : boolean ;
7+ buildReason : boolean ;
78} ;
89
910/**
@@ -29,5 +30,10 @@ export function featureSetForVersion(
2930 wildcardSSH :
3031 ( version ? version . compare ( "2.19.0" ) : - 1 ) >= 0 ||
3132 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" ,
3238 } ;
3339}
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ export class Remote {
6868 workspace : Workspace ,
6969 label : string ,
7070 binPath : string ,
71+ featureSet : FeatureSet ,
7172 ) : Promise < Workspace | undefined > {
7273 const workspaceName = `${ workspace . owner_name } /${ workspace . name } ` ;
7374
@@ -136,6 +137,7 @@ export class Remote {
136137 binPath ,
137138 workspace ,
138139 writeEmitter ,
140+ featureSet ,
139141 ) ;
140142 break ;
141143 case "failed" :
@@ -153,6 +155,7 @@ export class Remote {
153155 binPath ,
154156 workspace ,
155157 writeEmitter ,
158+ featureSet ,
156159 ) ;
157160 break ;
158161 }
@@ -383,6 +386,7 @@ export class Remote {
383386 workspace ,
384387 parts . label ,
385388 binaryPath ,
389+ featureSet ,
386390 ) ;
387391 if ( ! updatedWorkspace ) {
388392 // User declined to start the workspace.
You can’t perform that action at this time.
0 commit comments