@@ -689,7 +689,7 @@ index 3715cbb8e6ee41c3d9b5090918d243b723ae2d00..c65de8ad37e727d66da97a8f8b170cbc
689689-
690690-
691691diff --git a/src/vs/platform/remote/common/remoteAgentConnection.ts b/src/vs/platform/remote/common/remoteAgentConnection.ts
692- index 18d3d04fd20335975293e37b3b641120dd92da20..b9819d50683f40c41c8a3b1f71423a20916e8394 100644
692+ index 18d3d04fd20335975293e37b3b641120dd92da20..a06f20ece490dba5d88b41268cddaaf6b2f6b64a 100644
693693--- a/src/vs/platform/remote/common/remoteAgentConnection.ts
694694+++ b/src/vs/platform/remote/common/remoteAgentConnection.ts
695695@@ -92,7 +92,7 @@ async function connectToRemoteExtensionHostAgent(options: ISimpleConnectionOptio
@@ -701,12 +701,12 @@ index 18d3d04fd20335975293e37b3b641120dd92da20..b9819d50683f40c41c8a3b1f71423a20
701701 (err: any, socket: ISocket | undefined) => {
702702 if (err || !socket) {
703703 options.logService.error(`${logPrefix} socketFactory.connect() failed. Error:`);
704- @@ -331,12 +331,17 @@ export const enum PersistentConnectionEventType {
704+ @@ -331,12 +331,16 @@ export const enum PersistentConnectionEventType {
705705 }
706706 export class ConnectionLostEvent {
707707 public readonly type = PersistentConnectionEventType.ConnectionLost;
708708+ constructor(
709- + public readonly suppressPopup ?: boolean
709+ + public readonly connectionAttempt ?: number
710710+ ) { }
711711 }
712712 export class ReconnectionWaitEvent {
@@ -715,67 +715,68 @@ index 18d3d04fd20335975293e37b3b641120dd92da20..b9819d50683f40c41c8a3b1f71423a20
715715 public readonly durationSeconds: number,
716716- private readonly cancellableTimer: CancelablePromise<void>
717717+ private readonly cancellableTimer: CancelablePromise<void>,
718- + public readonly suppressPopup?: boolean,
719- + public readonly forceDialog?: boolean
718+ + public readonly connectionAttempt?: number,
720719 ) { }
721720
722721 public skipWait(): void {
723- @@ -345,12 +350 ,21 @@ export class ReconnectionWaitEvent {
722+ @@ -345,12 +349 ,21 @@ export class ReconnectionWaitEvent {
724723 }
725724 export class ReconnectionRunningEvent {
726725 public readonly type = PersistentConnectionEventType.ReconnectionRunning;
727726+ constructor(
728- + public readonly suppressPopup ?: boolean
727+ + public readonly connectionAttempt ?: number
729728+ ) { }
730729 }
731730 export class ConnectionGainEvent {
732731 public readonly type = PersistentConnectionEventType.ConnectionGain;
733732+ constructor(
734- + public readonly suppressPopup ?: boolean
733+ + public readonly connectionAttempt ?: number
735734+ ) { }
736735 }
737736 export class ReconnectionPermanentFailureEvent {
738737 public readonly type = PersistentConnectionEventType.ReconnectionPermanentFailure;
739738+ constructor(
740- + public readonly suppressPopup ?: boolean | undefined
739+ + public readonly connectionAttempt ?: number
741740+ ) { }
742741 }
743742 export type PersistenConnectionEvent = ConnectionGainEvent | ConnectionLostEvent | ReconnectionWaitEvent | ReconnectionRunningEvent | ReconnectionPermanentFailureEvent;
744743
745- @@ -411,16 +425,22 @@ abstract class PersistentConnection extends Disposable {
744+ @@ -411,8 +424,9 @@ abstract class PersistentConnection extends Disposable {
746745 }
747746 const logPrefix = commonLogPrefix(this._connectionType, this.reconnectionToken, true);
748747 this._options.logService.info(`${logPrefix} starting reconnecting loop. You can get more information with the trace log level.`);
749748- this._onDidStateChange.fire(new ConnectionLostEvent());
750- + let suppressPopup = true;
751- + let forceDialog = false;
752- + this._onDidStateChange.fire(new ConnectionLostEvent(suppressPopup));
749+ + this._onDidStateChange.fire(new ConnectionLostEvent(0));
753750 const TIMES = [5, 5, 10, 10, 10, 10, 10, 30];
754- + const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt
755751+
756752 const disconnectStartTime = Date.now();
757753 let attempt = -1;
758754 do {
759- attempt++;
760- + suppressPopup = (attempt < SHOW_POPUP_ON_ATTEMPT) ? true : false
761- + forceDialog = (attempt == SHOW_POPUP_ON_ATTEMPT)
755+ @@ -420,7 +434,7 @@ abstract class PersistentConnection extends Disposable {
762756 const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]);
763757 try {
764758 const sleepPromise = sleep(waitTime);
765759- this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise));
766- + this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise, suppressPopup, forceDialog ));
760+ + this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise, attempt ));
767761
768762 this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`);
769763 try {
770- @@ -433,7 +453,7 @@ abstract class PersistentConnection extends Disposable {
764+ @@ -433,13 +447,13 @@ abstract class PersistentConnection extends Disposable {
771765 }
772766
773767 // connection was lost, let's try to re-establish it
774768- this._onDidStateChange.fire(new ReconnectionRunningEvent());
775- + this._onDidStateChange.fire(new ReconnectionRunningEvent(suppressPopup ));
769+ + this._onDidStateChange.fire(new ReconnectionRunningEvent(attempt ));
776770 this._options.logService.info(`${logPrefix} resolving connection...`);
777771 const simpleOptions = await resolveConnectionOptions(this._options, this.reconnectionToken, this.protocol);
778772 this._options.logService.info(`${logPrefix} connecting to ${simpleOptions.host}:${simpleOptions.port}...`);
773+ await connectWithTimeLimit(simpleOptions.logService, this._reconnect(simpleOptions), RECONNECT_TIMEOUT);
774+ this._options.logService.info(`${logPrefix} reconnected!`);
775+ - this._onDidStateChange.fire(new ConnectionGainEvent());
776+ + this._onDidStateChange.fire(new ConnectionGainEvent(attempt));
777+
778+ break;
779+ } catch (err) {
779780diff --git a/src/vs/platform/storage/browser/storageService.ts b/src/vs/platform/storage/browser/storageService.ts
780781index ab3fd347b69f8a3d9b96e706cd87c911b8ffed6b..9d351037b577f9f1edfd18ae9b3c48a211f4467f 100644
781782--- a/src/vs/platform/storage/browser/storageService.ts
@@ -3275,16 +3276,28 @@ index 94e7e7a4bac154c45078a1b5034e50634a7a43af..8164200dcef1efbc65b50eef9c270af3
32753276 this._dirnameKey.set(value ? dirname(value).fsPath : null);
32763277 this._pathKey.set(value ? value.fsPath : null);
32773278diff --git a/src/vs/workbench/contrib/remote/browser/remote.ts b/src/vs/workbench/contrib/remote/browser/remote.ts
3278- index 98573a206f14928fc3fdf18fe927cb75034e4ad1..a031f76924abf8f10c510ea9c043f670c5b43074 100644
3279+ index 98573a206f14928fc3fdf18fe927cb75034e4ad1..1430666aa94f941bda086df503fec8b35aa2b25f 100644
32793280--- a/src/vs/workbench/contrib/remote/browser/remote.ts
32803281+++ b/src/vs/workbench/contrib/remote/browser/remote.ts
3281- @@ -795,31 +795,43 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
3282+ @@ -730,6 +730,7 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
3283+ @IContextKeyService contextKeyService: IContextKeyService
3284+ ) {
3285+ const connection = remoteAgentService.getConnection();
3286+ + const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt
3287+ if (connection) {
3288+ let visibleProgress: VisibleProgress | null = null;
3289+ let lastLocation: ProgressLocation.Dialog | ProgressLocation.Notification | null = null;
3290+ @@ -793,33 +794,47 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
3291+ disposableListener.dispose();
3292+ disposableListener = null;
32823293 }
3294+ + let suppressPopup = (typeof e.connectionAttempt == 'number' && e.connectionAttempt < SHOW_POPUP_ON_ATTEMPT)
3295+ + let forceDialog = (typeof e.connectionAttempt == 'number' && e.connectionAttempt == SHOW_POPUP_ON_ATTEMPT)
32833296 switch (e.type) {
32843297 case PersistentConnectionEventType.ConnectionLost:
32853298- if (!visibleProgress) {
32863299- visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]);
3287- + if (e. suppressPopup) {
3300+ + if (suppressPopup) {
32883301+ hideProgress()
32893302+ } else {
32903303+ if (!visibleProgress) {
@@ -3298,10 +3311,10 @@ index 98573a206f14928fc3fdf18fe927cb75034e4ad1..a031f76924abf8f10c510ea9c043f670
32983311 reconnectWaitEvent = e;
32993312- visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reconnectButton, reloadButton]);
33003313- visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds);
3301- + if (e. suppressPopup) {
3314+ + if (suppressPopup) {
33023315+ hideProgress()
33033316+ } else {
3304- + const location = e. forceDialog ? ProgressLocation.Dialog : (lastLocation || ProgressLocation.Notification)
3317+ + const location = forceDialog ? ProgressLocation.Dialog : (lastLocation || ProgressLocation.Notification)
33053318+ visibleProgress = showProgress(location, [reconnectButton, reloadButton]);
33063319+ visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds);
33073320+ }
@@ -3317,7 +3330,7 @@ index 98573a206f14928fc3fdf18fe927cb75034e4ad1..a031f76924abf8f10c510ea9c043f670
33173330- // Need to move from dialog if being shown and user needs to type in a prompt
33183331- if (lastLocation === ProgressLocation.Dialog && visibleProgress !== null) {
33193332- visibleProgress = showProgress(ProgressLocation.Notification, [reloadButton], visibleProgress.lastReport);
3320- + if (e. suppressPopup) {
3333+ + if (suppressPopup) {
33213334+ hideProgress()
33223335+ } else {
33233336+ visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton]);
0 commit comments