Skip to content

Commit

Permalink
Fix continuation microsoft#175107 when the remote takes more than 20s…
Browse files Browse the repository at this point in the history
… to resolve, e.g. codespaces
  • Loading branch information
jeanp413 committed May 8, 2023
1 parent 87de3d6 commit 91b2f7b
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ export class TerminalProfileService implements ITerminalProfileService {
declare _serviceBrand: undefined;

private _webExtensionContributedProfileContextKey: IContextKey<boolean>;
private _profilesReadyBarrier: AutoOpenBarrier;
private _availableProfiles: ITerminalProfile[] | undefined;
private _profilesReadyBarrier: AutoOpenBarrier | undefined;
private _profilesReadyPromise: Promise<void>;
private _contributedProfiles: IExtensionTerminalProfile[] = [];
private _defaultProfileName?: string;
private _platformConfigJustRefreshed = false;
Expand All @@ -41,7 +42,7 @@ export class TerminalProfileService implements ITerminalProfileService {
private readonly _onDidChangeAvailableProfiles = new Emitter<ITerminalProfile[]>();
get onDidChangeAvailableProfiles(): Event<ITerminalProfile[]> { return this._onDidChangeAvailableProfiles.event; }

get profilesReady(): Promise<void> { return this._profilesReadyBarrier.wait().then(() => { }); }
get profilesReady(): Promise<void> { return this._profilesReadyPromise; }
get availableProfiles(): ITerminalProfile[] {
if (!this._platformConfigJustRefreshed) {
this.refreshAvailableProfiles();
Expand All @@ -59,18 +60,22 @@ export class TerminalProfileService implements ITerminalProfileService {
@IExtensionService private readonly _extensionService: IExtensionService,
@IRemoteAgentService private _remoteAgentService: IRemoteAgentService,
@IWorkbenchEnvironmentService private readonly _environmentService: IWorkbenchEnvironmentService,
@ITerminalInstanceService private readonly _terminalInstanceService: ITerminalInstanceService
@ITerminalInstanceService private readonly _terminalInstanceService: ITerminalInstanceService,
) {
// in web, we don't want to show the dropdown unless there's a web extension
// that contributes a profile
this._extensionService.onDidChangeExtensions(() => this.refreshAvailableProfiles());

this._webExtensionContributedProfileContextKey = TerminalContextKeys.webExtensionContributedProfile.bindTo(this._contextKeyService);
this._updateWebContextKey();
// Wait up to 5 seconds for profiles to be ready so it's assured that we know the actual
// default terminal before launching the first terminal. This isn't expected to ever take
// this long.
this._profilesReadyBarrier = new AutoOpenBarrier(20000);
this._profilesReadyPromise = this._remoteAgentService.getEnvironment()
.then(() => {
// Wait up to 20 seconds for profiles to be ready so it's assured that we know the actual
// default terminal before launching the first terminal. This isn't expected to ever take
// this long.
this._profilesReadyBarrier = new AutoOpenBarrier(20000);
return this._profilesReadyBarrier.wait().then(() => { });
});
this.refreshAvailableProfiles();
this._setupConfigListener();
}
Expand Down Expand Up @@ -138,7 +143,7 @@ export class TerminalProfileService implements ITerminalProfileService {
if (profilesChanged || contributedProfilesChanged) {
this._availableProfiles = profiles;
this._onDidChangeAvailableProfiles.fire(this._availableProfiles);
this._profilesReadyBarrier.open();
this._profilesReadyBarrier!.open();
this._updateWebContextKey();
await this._refreshPlatformConfig(this._availableProfiles);
}
Expand Down

0 comments on commit 91b2f7b

Please sign in to comment.