@@ -16,6 +16,7 @@ import { CodeCatalystAuthenticationProvider } from './auth'
16
16
import { getCodeCatalystDevEnvId } from '../shared/vscode/env'
17
17
import globals from '../shared/extensionGlobals'
18
18
import { isDevenvVscode , recordSource } from './utils'
19
+ import { SsoConnection } from '../credentials/auth'
19
20
20
21
const localize = nls . loadMessageBundle ( )
21
22
@@ -30,14 +31,13 @@ export function watchRestartingDevEnvs(ctx: ExtContext, authProvider: CodeCataly
30
31
}
31
32
getLogger ( ) . info ( `codecatalyst: reconnect: onDidChangeActiveConnection: startUrl=${ conn . startUrl } ` )
32
33
33
- const client = await createClient ( conn )
34
34
const envId = getCodeCatalystDevEnvId ( )
35
- handleRestart ( client , ctx , envId )
35
+ handleRestart ( conn , ctx , envId )
36
36
restartHandled = true
37
37
} )
38
38
}
39
39
40
- function handleRestart ( client : CodeCatalystClient , ctx : ExtContext , envId : string | undefined ) {
40
+ function handleRestart ( conn : SsoConnection , ctx : ExtContext , envId : string | undefined ) {
41
41
if ( envId !== undefined ) {
42
42
const memento = ctx . extensionContext . globalState
43
43
const pendingReconnects = memento . get < Record < string , DevEnvMemento > > ( codecatalystReconnectKey , { } )
@@ -55,18 +55,18 @@ function handleRestart(client: CodeCatalystClient, ctx: ExtContext, envId: strin
55
55
getLogger ( ) . info ( 'codecatalyst: attempting to poll dev environments' )
56
56
57
57
// Reconnect devenvs (if coming from a restart)
58
- reconnectDevEnvs ( client , ctx ) . catch ( err => {
58
+ reconnectDevEnvs ( conn , ctx ) . catch ( err => {
59
59
getLogger ( ) . error ( `codecatalyst: error while resuming devenvs: ${ err } ` )
60
60
} )
61
61
}
62
62
}
63
63
64
64
/**
65
65
* Attempt to poll for connection in all valid devenvs
66
- * @param client a connected client
66
+ * @param conn a connection that may be used for CodeCatalyst
67
67
* @param ctx the extension context
68
68
*/
69
- async function reconnectDevEnvs ( client : CodeCatalystClient , ctx : ExtContext ) : Promise < void > {
69
+ async function reconnectDevEnvs ( conn : SsoConnection , ctx : ExtContext ) : Promise < void > {
70
70
const memento = ctx . extensionContext . globalState
71
71
const pendingDevEnvs = memento . get < Record < string , DevEnvMemento > > ( codecatalystReconnectKey , { } )
72
72
const validDevEnvs = filterInvalidDevEnvs ( pendingDevEnvs )
@@ -85,12 +85,14 @@ async function reconnectDevEnvs(client: CodeCatalystClient, ctx: ExtContext): Pr
85
85
'Dev Environments restarting: {0}' ,
86
86
polledDevEnvs
87
87
)
88
- vscode . window . withProgress (
88
+ await vscode . window . withProgress (
89
89
{
90
90
location : vscode . ProgressLocation . Notification ,
91
91
} ,
92
- ( progress , token ) => {
92
+ async ( progress , token ) => {
93
93
progress . report ( { message : progressTitle } )
94
+ const client = await createClient ( conn )
95
+
94
96
return pollDevEnvs ( client , progress , token , memento , validDevEnvs )
95
97
}
96
98
)
0 commit comments