@@ -53,6 +53,7 @@ export class Remote {
53
53
private async maybeWaitForRunning (
54
54
restClient : Api ,
55
55
workspace : Workspace ,
56
+ label : string ,
56
57
binPath : string ,
57
58
) : Promise < Workspace | undefined > {
58
59
// Maybe already running?
@@ -98,6 +99,7 @@ export class Remote {
98
99
title : "Waiting for workspace build..." ,
99
100
} ,
100
101
async ( ) => {
102
+ const globalConfigDir = path . dirname ( this . storage . getSessionTokenPath ( label ) )
101
103
while ( workspace . latest_build . status !== "running" ) {
102
104
++ attempts
103
105
switch ( workspace . latest_build . status ) {
@@ -114,7 +116,13 @@ export class Remote {
114
116
}
115
117
writeEmitter = initWriteEmitterAndTerminal ( )
116
118
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
+ )
118
126
break
119
127
case "failed" :
120
128
// On a first attempt, we will try starting a failed workspace
@@ -125,7 +133,13 @@ export class Remote {
125
133
}
126
134
writeEmitter = initWriteEmitterAndTerminal ( )
127
135
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
+ )
129
143
break
130
144
}
131
145
// Otherwise fall through and error.
@@ -167,6 +181,9 @@ export class Remote {
167
181
168
182
const workspaceName = `${ parts . username } /${ parts . workspace } `
169
183
184
+ // Migrate "session_token" file to "session", if needed.
185
+ this . storage . migrateSessionToken ( parts . label )
186
+
170
187
// Get the URL and token belonging to this host.
171
188
const { url : baseUrlRaw , token } = await this . storage . readCliConfig ( parts . label )
172
189
@@ -303,7 +320,7 @@ export class Remote {
303
320
disposables . push ( this . registerLabelFormatter ( remoteAuthority , workspace . owner_name , workspace . name ) )
304
321
305
322
// 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 )
307
324
if ( ! updatedWorkspace ) {
308
325
// User declined to start the workspace.
309
326
await this . closeRemote ( )
0 commit comments