@@ -33,7 +33,7 @@ export class OpenContextRuntime implements Runtime {
33
33
private shellEvaluator : ShellEvaluator ;
34
34
private instanceState : ShellInstanceState ;
35
35
private evaluationListener : RuntimeEvaluationListener | null = null ;
36
- private updatedConnectionInfo = false ;
36
+ private updatedConnectionInfoPromise : Promise < void > | null = null ;
37
37
38
38
constructor (
39
39
serviceProvider : ServiceProvider ,
@@ -49,9 +49,9 @@ export class OpenContextRuntime implements Runtime {
49
49
50
50
async getCompletions ( code : string ) : Promise < Completion [ ] > {
51
51
if ( ! this . autocompleter ) {
52
- await this . instanceState . fetchConnectionInfo ( ) ;
53
- this . updatedConnectionInfo = true ;
54
52
this . autocompleter = new ShellApiAutocompleter ( this . instanceState . getAutocompleteParameters ( ) ) ;
53
+ this . updatedConnectionInfoPromise ??= this . instanceState . fetchConnectionInfo ( ) ;
54
+ await this . updatedConnectionInfoPromise ;
55
55
}
56
56
57
57
return this . autocompleter . getCompletions ( code ) ;
@@ -76,10 +76,8 @@ export class OpenContextRuntime implements Runtime {
76
76
}
77
77
78
78
async getShellPrompt ( ) : Promise < string > {
79
- if ( ! this . updatedConnectionInfo ) {
80
- await this . instanceState . fetchConnectionInfo ( ) ;
81
- this . updatedConnectionInfo = true ;
82
- }
79
+ this . updatedConnectionInfoPromise ??= this . instanceState . fetchConnectionInfo ( ) ;
80
+ await this . updatedConnectionInfoPromise ;
83
81
return await this . instanceState . getDefaultPrompt ( ) ;
84
82
}
85
83
}
0 commit comments