@@ -56,11 +56,6 @@ export class Remote {
5656 label : string ,
5757 binPath : string ,
5858 ) : Promise < Workspace | undefined > {
59- // Maybe already running?
60- if ( workspace . latest_build . status === "running" ) {
61- return workspace
62- }
63-
6459 const workspaceName = `${ workspace . owner_name } /${ workspace . name } `
6560
6661 // A terminal will be used to stream the build, if one is necessary.
@@ -320,13 +315,19 @@ export class Remote {
320315 disposables . push ( this . registerLabelFormatter ( remoteAuthority , workspace . owner_name , workspace . name ) )
321316
322317 // If the workspace is not in a running state, try to get it running.
323- const updatedWorkspace = await this . maybeWaitForRunning ( workspaceRestClient , workspace , parts . label , binaryPath )
324- if ( ! updatedWorkspace ) {
325- // User declined to start the workspace.
326- await this . closeRemote ( )
318+ if ( workspace . latest_build . status !== "running" ) {
319+ if ( ! ( await this . maybeWaitForRunning ( workspaceRestClient , workspace , parts . label , binaryPath ) ) ) {
320+ // User declined to start the workspace.
321+ await this . closeRemote ( )
322+ } else {
323+ // Start over with a fresh REST client because we may have waited an
324+ // indeterminate amount amount of time for confirmation to start the
325+ // workspace.
326+ await this . setup ( remoteAuthority )
327+ }
327328 return
328329 }
329- this . commands . workspace = workspace = updatedWorkspace
330+ this . commands . workspace = workspace
330331
331332 // Pick an agent.
332333 this . storage . writeToCoderOutputChannel ( `Finding agent for ${ workspaceName } ...` )
0 commit comments