@@ -53,6 +53,7 @@ export class Remote {
5353 private async maybeWaitForRunning (
5454 restClient : Api ,
5555 workspace : Workspace ,
56+ label : string ,
5657 binPath : string ,
5758 ) : Promise < Workspace | undefined > {
5859 // Maybe already running?
@@ -98,6 +99,7 @@ export class Remote {
9899 title : "Waiting for workspace build..." ,
99100 } ,
100101 async ( ) => {
102+ const globalConfigDir = path . dirname ( this . storage . getSessionTokenPath ( label ) )
101103 while ( workspace . latest_build . status !== "running" ) {
102104 ++ attempts
103105 switch ( workspace . latest_build . status ) {
@@ -114,7 +116,13 @@ export class Remote {
114116 }
115117 writeEmitter = initWriteEmitterAndTerminal ( )
116118 this . storage . writeToCoderOutputChannel ( `Starting ${ workspaceName } ...` )
117- workspace = await startWorkspaceIfStoppedOrFailed ( restClient , binPath , workspace , writeEmitter )
119+ workspace = await startWorkspaceIfStoppedOrFailed (
120+ restClient ,
121+ globalConfigDir ,
122+ binPath ,
123+ workspace ,
124+ writeEmitter ,
125+ )
118126 break
119127 case "failed" :
120128 // On a first attempt, we will try starting a failed workspace
@@ -125,7 +133,13 @@ export class Remote {
125133 }
126134 writeEmitter = initWriteEmitterAndTerminal ( )
127135 this . storage . writeToCoderOutputChannel ( `Starting ${ workspaceName } ...` )
128- workspace = await startWorkspaceIfStoppedOrFailed ( restClient , binPath , workspace , writeEmitter )
136+ workspace = await startWorkspaceIfStoppedOrFailed (
137+ restClient ,
138+ globalConfigDir ,
139+ binPath ,
140+ workspace ,
141+ writeEmitter ,
142+ )
129143 break
130144 }
131145 // Otherwise fall through and error.
@@ -167,6 +181,9 @@ export class Remote {
167181
168182 const workspaceName = `${ parts . username } /${ parts . workspace } `
169183
184+ // Migrate "session_token" file to "session", if needed.
185+ this . storage . migrateSessionToken ( parts . label )
186+
170187 // Get the URL and token belonging to this host.
171188 const { url : baseUrlRaw , token } = await this . storage . readCliConfig ( parts . label )
172189
@@ -303,7 +320,7 @@ export class Remote {
303320 disposables . push ( this . registerLabelFormatter ( remoteAuthority , workspace . owner_name , workspace . name ) )
304321
305322 // If the workspace is not in a running state, try to get it running.
306- const updatedWorkspace = await this . maybeWaitForRunning ( workspaceRestClient , workspace , binaryPath )
323+ const updatedWorkspace = await this . maybeWaitForRunning ( workspaceRestClient , workspace , parts . label , binaryPath )
307324 if ( ! updatedWorkspace ) {
308325 // User declined to start the workspace.
309326 await this . closeRemote ( )
0 commit comments