From 67e2a99df2799b686a96f0c51f00ff89d68f555c Mon Sep 17 00:00:00 2001 From: "Machado, Meygha" Date: Fri, 6 Nov 2020 16:49:03 -0600 Subject: [PATCH 1/8] show popup on third attempt --- ci/dev/vscode.patch | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/ci/dev/vscode.patch b/ci/dev/vscode.patch index ad613305..6e46f83d 100644 --- a/ci/dev/vscode.patch +++ b/ci/dev/vscode.patch @@ -746,6 +746,53 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367 (err: any, socket: ISocket | undefined) => { if (err || !socket) { options.logService.error(`${logPrefix} socketFactory.connect() failed. Error:`); +@@ -411,16 +411,23 @@ abstract class PersistentConnection extends Disposable { + } + const logPrefix = commonLogPrefix(this._connectionType, this.reconnectionToken, true); + this._options.logService.info(`${logPrefix} starting reconnecting loop. You can get more information with the trace log level.`); +- this._onDidStateChange.fire(new ConnectionLostEvent()); + const TIMES = [5, 5, 10, 10, 10, 10, 10, 30]; ++ const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt ++ + const disconnectStartTime = Date.now(); + let attempt = -1; + do { + attempt++; ++ if (attempt == SHOW_POPUP_ON_ATTEMPT){ ++ this._onDidStateChange.fire(new ConnectionLostEvent()); ++ } ++ + const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]); + try { + const sleepPromise = sleep(waitTime); +- this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise)); ++ if (attempt >= SHOW_POPUP_ON_ATTEMPT) { ++ this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise)); ++ } + + this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`); + try { +@@ -433,14 +440,17 @@ abstract class PersistentConnection extends Disposable { + } + + // connection was lost, let's try to re-establish it +- this._onDidStateChange.fire(new ReconnectionRunningEvent()); ++ if (attempt >= SHOW_POPUP_ON_ATTEMPT){ ++ this._onDidStateChange.fire(new ReconnectionRunningEvent()); ++ } + this._options.logService.info(`${logPrefix} resolving connection...`); + const simpleOptions = await resolveConnectionOptions(this._options, this.reconnectionToken, this.protocol); + this._options.logService.info(`${logPrefix} connecting to ${simpleOptions.host}:${simpleOptions.port}...`); + await connectWithTimeLimit(simpleOptions.logService, this._reconnect(simpleOptions), RECONNECT_TIMEOUT); + this._options.logService.info(`${logPrefix} reconnected!`); +- this._onDidStateChange.fire(new ConnectionGainEvent()); +- ++ if (attempt >= SHOW_POPUP_ON_ATTEMPT) { ++ this._onDidStateChange.fire(new ConnectionGainEvent()); ++ } + break; + } catch (err) { + if (err.code === 'VSCODE_CONNECTION_ERROR') { diff --git a/src/vs/platform/storage/browser/storageService.ts b/src/vs/platform/storage/browser/storageService.ts index ab3fd347b69f8a3d9b96e706cd87c911b8ffed6b..9d351037b577f9f1edfd18ae9b3c48a211f4467f 100644 --- a/src/vs/platform/storage/browser/storageService.ts From 290c533c8ede1902705e6e672aee19539e2604fe Mon Sep 17 00:00:00 2001 From: "Machado, Meygha" Date: Mon, 16 Nov 2020 11:39:21 -0600 Subject: [PATCH 2/8] turn off visibleProgress on ConnectionLost --- ci/dev/vscode.patch | 63 ++++++++++++++++----------------------------- 1 file changed, 22 insertions(+), 41 deletions(-) diff --git a/ci/dev/vscode.patch b/ci/dev/vscode.patch index 6e46f83d..d1a5112d 100644 --- a/ci/dev/vscode.patch +++ b/ci/dev/vscode.patch @@ -746,53 +746,15 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367 (err: any, socket: ISocket | undefined) => { if (err || !socket) { options.logService.error(`${logPrefix} socketFactory.connect() failed. Error:`); -@@ -411,16 +411,23 @@ abstract class PersistentConnection extends Disposable { - } - const logPrefix = commonLogPrefix(this._connectionType, this.reconnectionToken, true); +@@ -413,6 +413,8 @@ abstract class PersistentConnection extends Disposable { this._options.logService.info(`${logPrefix} starting reconnecting loop. You can get more information with the trace log level.`); -- this._onDidStateChange.fire(new ConnectionLostEvent()); + this._onDidStateChange.fire(new ConnectionLostEvent()); const TIMES = [5, 5, 10, 10, 10, 10, 10, 30]; -+ const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt ++ // const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt + const disconnectStartTime = Date.now(); let attempt = -1; do { - attempt++; -+ if (attempt == SHOW_POPUP_ON_ATTEMPT){ -+ this._onDidStateChange.fire(new ConnectionLostEvent()); -+ } -+ - const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]); - try { - const sleepPromise = sleep(waitTime); -- this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise)); -+ if (attempt >= SHOW_POPUP_ON_ATTEMPT) { -+ this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise)); -+ } - - this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`); - try { -@@ -433,14 +440,17 @@ abstract class PersistentConnection extends Disposable { - } - - // connection was lost, let's try to re-establish it -- this._onDidStateChange.fire(new ReconnectionRunningEvent()); -+ if (attempt >= SHOW_POPUP_ON_ATTEMPT){ -+ this._onDidStateChange.fire(new ReconnectionRunningEvent()); -+ } - this._options.logService.info(`${logPrefix} resolving connection...`); - const simpleOptions = await resolveConnectionOptions(this._options, this.reconnectionToken, this.protocol); - this._options.logService.info(`${logPrefix} connecting to ${simpleOptions.host}:${simpleOptions.port}...`); - await connectWithTimeLimit(simpleOptions.logService, this._reconnect(simpleOptions), RECONNECT_TIMEOUT); - this._options.logService.info(`${logPrefix} reconnected!`); -- this._onDidStateChange.fire(new ConnectionGainEvent()); -- -+ if (attempt >= SHOW_POPUP_ON_ATTEMPT) { -+ this._onDidStateChange.fire(new ConnectionGainEvent()); -+ } - break; - } catch (err) { - if (err.code === 'VSCODE_CONNECTION_ERROR') { diff --git a/src/vs/platform/storage/browser/storageService.ts b/src/vs/platform/storage/browser/storageService.ts index ab3fd347b69f8a3d9b96e706cd87c911b8ffed6b..9d351037b577f9f1edfd18ae9b3c48a211f4467f 100644 --- a/src/vs/platform/storage/browser/storageService.ts @@ -3922,6 +3884,25 @@ index 94e7e7a4bac154c45078a1b5034e50634a7a43af..8164200dcef1efbc65b50eef9c270af3 this._filenameKey.set(value ? basename(value) : null); this._dirnameKey.set(value ? dirname(value).fsPath : null); this._pathKey.set(value ? value.fsPath : null); +diff --git a/src/vs/workbench/contrib/remote/browser/remote.ts b/src/vs/workbench/contrib/remote/browser/remote.ts +index 98573a206f14928fc3fdf18fe927cb75034e4ad1..2f6a2fd6733e286024d20530773e3fbc26ffe16c 100644 +--- a/src/vs/workbench/contrib/remote/browser/remote.ts ++++ b/src/vs/workbench/contrib/remote/browser/remote.ts +@@ -795,10 +795,10 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution { + } + switch (e.type) { + case PersistentConnectionEventType.ConnectionLost: +- if (!visibleProgress) { +- visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]); +- } +- visibleProgress.report(nls.localize('connectionLost', "Connection Lost")); ++ // if (!visibleProgress) { ++ // visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]); ++ // } ++ // visibleProgress.report(nls.localize('connectionLost', "Connection Lost")); + break; + case PersistentConnectionEventType.ReconnectionWait: + reconnectWaitEvent = e; diff --git a/src/vs/workbench/contrib/scm/browser/media/scm.css b/src/vs/workbench/contrib/scm/browser/media/scm.css index 74f6922e98b4bb6a7fb100f5aac015afe9fc171b..3243a97c2d378013d96ffbe87e9df6dd4a66776d 100644 --- a/src/vs/workbench/contrib/scm/browser/media/scm.css From 4eb43751196ed9e72e097674aefd5913a84f2fa1 Mon Sep 17 00:00:00 2001 From: "Machado, Meygha" Date: Mon, 16 Nov 2020 17:34:38 -0600 Subject: [PATCH 3/8] one working solution without event suppression --- ci/dev/vscode.patch | 149 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 136 insertions(+), 13 deletions(-) diff --git a/ci/dev/vscode.patch b/ci/dev/vscode.patch index d1a5112d..c31a5a60 100644 --- a/ci/dev/vscode.patch +++ b/ci/dev/vscode.patch @@ -746,15 +746,78 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367 (err: any, socket: ISocket | undefined) => { if (err || !socket) { options.logService.error(`${logPrefix} socketFactory.connect() failed. Error:`); -@@ -413,6 +413,8 @@ abstract class PersistentConnection extends Disposable { +@@ -331,12 +331,16 @@ export const enum PersistentConnectionEventType { + } + export class ConnectionLostEvent { + public readonly type = PersistentConnectionEventType.ConnectionLost; ++ constructor( ++ public readonly suppressPopup?: boolean ++ ) { } + } + export class ReconnectionWaitEvent { + public readonly type = PersistentConnectionEventType.ReconnectionWait; + constructor( + public readonly durationSeconds: number, +- private readonly cancellableTimer: CancelablePromise ++ private readonly cancellableTimer: CancelablePromise, ++ public readonly suppressPopup?: boolean + ) { } + + public skipWait(): void { +@@ -345,12 +349,21 @@ export class ReconnectionWaitEvent { + } + export class ReconnectionRunningEvent { + public readonly type = PersistentConnectionEventType.ReconnectionRunning; ++ constructor( ++ public readonly suppressPopup?: boolean ++ ) { } + } + export class ConnectionGainEvent { + public readonly type = PersistentConnectionEventType.ConnectionGain; ++ constructor( ++ public readonly suppressPopup?: boolean ++ ) { } + } + export class ReconnectionPermanentFailureEvent { + public readonly type = PersistentConnectionEventType.ReconnectionPermanentFailure; ++ constructor( ++ public readonly suppressPopup?: boolean | undefined ++ ) { } + } + export type PersistenConnectionEvent = ConnectionGainEvent | ConnectionLostEvent | ReconnectionWaitEvent | ReconnectionRunningEvent | ReconnectionPermanentFailureEvent; + +@@ -411,16 +424,20 @@ abstract class PersistentConnection extends Disposable { + } + const logPrefix = commonLogPrefix(this._connectionType, this.reconnectionToken, true); this._options.logService.info(`${logPrefix} starting reconnecting loop. You can get more information with the trace log level.`); - this._onDidStateChange.fire(new ConnectionLostEvent()); +- this._onDidStateChange.fire(new ConnectionLostEvent()); ++ let suppressPopup = true; ++ this._onDidStateChange.fire(new ConnectionLostEvent(suppressPopup)); const TIMES = [5, 5, 10, 10, 10, 10, 10, 30]; -+ // const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt ++ const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt + const disconnectStartTime = Date.now(); let attempt = -1; do { + attempt++; ++ suppressPopup = (attempt < SHOW_POPUP_ON_ATTEMPT) ? true : false + const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]); + try { + const sleepPromise = sleep(waitTime); +- this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise)); ++ this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise, suppressPopup)); + + this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`); + try { +@@ -433,7 +450,7 @@ abstract class PersistentConnection extends Disposable { + } + + // connection was lost, let's try to re-establish it +- this._onDidStateChange.fire(new ReconnectionRunningEvent()); ++ this._onDidStateChange.fire(new ReconnectionRunningEvent(suppressPopup)); + this._options.logService.info(`${logPrefix} resolving connection...`); + const simpleOptions = await resolveConnectionOptions(this._options, this.reconnectionToken, this.protocol); + this._options.logService.info(`${logPrefix} connecting to ${simpleOptions.host}:${simpleOptions.port}...`); diff --git a/src/vs/platform/storage/browser/storageService.ts b/src/vs/platform/storage/browser/storageService.ts index ab3fd347b69f8a3d9b96e706cd87c911b8ffed6b..9d351037b577f9f1edfd18ae9b3c48a211f4467f 100644 --- a/src/vs/platform/storage/browser/storageService.ts @@ -3885,24 +3948,84 @@ index 94e7e7a4bac154c45078a1b5034e50634a7a43af..8164200dcef1efbc65b50eef9c270af3 this._dirnameKey.set(value ? dirname(value).fsPath : null); this._pathKey.set(value ? value.fsPath : null); diff --git a/src/vs/workbench/contrib/remote/browser/remote.ts b/src/vs/workbench/contrib/remote/browser/remote.ts -index 98573a206f14928fc3fdf18fe927cb75034e4ad1..2f6a2fd6733e286024d20530773e3fbc26ffe16c 100644 +index 98573a206f14928fc3fdf18fe927cb75034e4ad1..3ffe27b816e2d0a630985a24dd1af910877c2295 100644 --- a/src/vs/workbench/contrib/remote/browser/remote.ts +++ b/src/vs/workbench/contrib/remote/browser/remote.ts -@@ -795,10 +795,10 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution { - } +@@ -635,7 +635,7 @@ class VisibleProgress { + return this._lastReport; + } + +- constructor(progressService: IProgressService, location: ProgressLocation, initialReport: string | null, buttons: string[], onDidCancel: (choice: number | undefined, lastReport: string | null) => void) { ++ constructor(progressService: IProgressService, location: ProgressLocation, initialReport: string | null, buttons: string[], onDidCancel: (choice: number | undefined, lastReport: string | null) => void, suppressPopup: Boolean | undefined) { + this._isDisposed = false; + this._lastReport = initialReport; + this._currentProgressPromiseResolve = null; +@@ -644,8 +644,10 @@ class VisibleProgress { + + const promise = new Promise((resolve) => this._currentProgressPromiseResolve = resolve); + ++ const options = suppressPopup ? { location: location, buttons: buttons, silent: suppressPopup } : { location: location, buttons: buttons } ++ + progressService.withProgress( +- { location: location, buttons: buttons }, ++ options, + (progress) => { if (!this._isDisposed) { this._currentProgress = progress; } return promise; }, + (choice) => onDidCancel(choice, this._lastReport) + ); +@@ -736,7 +738,7 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution { + let reconnectWaitEvent: ReconnectionWaitEvent | null = null; + let disposableListener: IDisposable | null = null; + +- function showProgress(location: ProgressLocation.Dialog | ProgressLocation.Notification, buttons: { label: string, callback: () => void }[], initialReport: string | null = null): VisibleProgress { ++ function showProgress(location: ProgressLocation.Dialog | ProgressLocation.Notification, buttons: { label: string, callback: () => void }[], initialReport: string | null = null, suppressPopup: Boolean | undefined): VisibleProgress { + if (visibleProgress) { + visibleProgress.dispose(); + visibleProgress = null; +@@ -752,12 +754,12 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution { + buttons[choice].callback(); + } else { + if (location === ProgressLocation.Dialog) { +- visibleProgress = showProgress(ProgressLocation.Notification, buttons, lastReport); ++ visibleProgress = showProgress(ProgressLocation.Notification, buttons, lastReport, suppressPopup); + } else { + hideProgress(); + } + } +- } ++ }, suppressPopup + ); + } + +@@ -796,17 +798,17 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution { switch (e.type) { case PersistentConnectionEventType.ConnectionLost: -- if (!visibleProgress) { + if (!visibleProgress) { - visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]); -- } -- visibleProgress.report(nls.localize('connectionLost', "Connection Lost")); -+ // if (!visibleProgress) { -+ // visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]); -+ // } -+ // visibleProgress.report(nls.localize('connectionLost', "Connection Lost")); ++ visibleProgress = showProgress(ProgressLocation.Notification, [reconnectButton, reloadButton], null, e.suppressPopup); + } + visibleProgress.report(nls.localize('connectionLost', "Connection Lost")); break; case PersistentConnectionEventType.ReconnectionWait: reconnectWaitEvent = e; +- visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reconnectButton, reloadButton]); ++ visibleProgress = showProgress(lastLocation || ProgressLocation.Dialog, [reconnectButton, reloadButton], null, e.suppressPopup); + visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds); + break; + case PersistentConnectionEventType.ReconnectionRunning: +- visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton]); ++ visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton], null, e.suppressPopup); + visibleProgress.report(nls.localize('reconnectionRunning', "Attempting to reconnect...")); + + // Register to listen for quick input is opened +@@ -815,7 +817,7 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution { + if (contextKeyChangeEvent.affectsSome(reconnectInteraction)) { + // Need to move from dialog if being shown and user needs to type in a prompt + if (lastLocation === ProgressLocation.Dialog && visibleProgress !== null) { +- visibleProgress = showProgress(ProgressLocation.Notification, [reloadButton], visibleProgress.lastReport); ++ visibleProgress = showProgress(ProgressLocation.Notification, [reloadButton], visibleProgress.lastReport, e.suppressPopup); + } + } + }); diff --git a/src/vs/workbench/contrib/scm/browser/media/scm.css b/src/vs/workbench/contrib/scm/browser/media/scm.css index 74f6922e98b4bb6a7fb100f5aac015afe9fc171b..3243a97c2d378013d96ffbe87e9df6dd4a66776d 100644 --- a/src/vs/workbench/contrib/scm/browser/media/scm.css From a898dd34b9555b8f19e6b1bb20f01b90b1b99fb9 Mon Sep 17 00:00:00 2001 From: "Machado, Meygha" Date: Tue, 17 Nov 2020 10:58:25 -0600 Subject: [PATCH 4/8] solution with forceDialog for attempt 3 and no change to VisibleProgress class --- ci/dev/vscode.patch | 131 +++++++++++++++++++++----------------------- 1 file changed, 61 insertions(+), 70 deletions(-) diff --git a/ci/dev/vscode.patch b/ci/dev/vscode.patch index c31a5a60..2311d318 100644 --- a/ci/dev/vscode.patch +++ b/ci/dev/vscode.patch @@ -746,7 +746,7 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367 (err: any, socket: ISocket | undefined) => { if (err || !socket) { options.logService.error(`${logPrefix} socketFactory.connect() failed. Error:`); -@@ -331,12 +331,16 @@ export const enum PersistentConnectionEventType { +@@ -331,12 +331,17 @@ export const enum PersistentConnectionEventType { } export class ConnectionLostEvent { public readonly type = PersistentConnectionEventType.ConnectionLost; @@ -760,11 +760,12 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367 public readonly durationSeconds: number, - private readonly cancellableTimer: CancelablePromise + private readonly cancellableTimer: CancelablePromise, -+ public readonly suppressPopup?: boolean ++ public readonly suppressPopup?: boolean, ++ public readonly forceDialog?: boolean ) { } public skipWait(): void { -@@ -345,12 +349,21 @@ export class ReconnectionWaitEvent { +@@ -345,12 +350,21 @@ export class ReconnectionWaitEvent { } export class ReconnectionRunningEvent { public readonly type = PersistentConnectionEventType.ReconnectionRunning; @@ -786,14 +787,16 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367 } export type PersistenConnectionEvent = ConnectionGainEvent | ConnectionLostEvent | ReconnectionWaitEvent | ReconnectionRunningEvent | ReconnectionPermanentFailureEvent; -@@ -411,16 +424,20 @@ abstract class PersistentConnection extends Disposable { +@@ -411,16 +425,22 @@ abstract class PersistentConnection extends Disposable { } const logPrefix = commonLogPrefix(this._connectionType, this.reconnectionToken, true); this._options.logService.info(`${logPrefix} starting reconnecting loop. You can get more information with the trace log level.`); - this._onDidStateChange.fire(new ConnectionLostEvent()); +- const TIMES = [5, 5, 10, 10, 10, 10, 10, 30]; + let suppressPopup = true; ++ let forceDialog = false; + this._onDidStateChange.fire(new ConnectionLostEvent(suppressPopup)); - const TIMES = [5, 5, 10, 10, 10, 10, 10, 30]; ++ const TIMES = [1, 2, 3, 10, 10, 10, 10, 30]; + const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt + const disconnectStartTime = Date.now(); @@ -801,15 +804,16 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367 do { attempt++; + suppressPopup = (attempt < SHOW_POPUP_ON_ATTEMPT) ? true : false ++ forceDialog = (attempt == SHOW_POPUP_ON_ATTEMPT) const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]); try { const sleepPromise = sleep(waitTime); - this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise)); -+ this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise, suppressPopup)); ++ this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise, suppressPopup, forceDialog)); this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`); try { -@@ -433,7 +450,7 @@ abstract class PersistentConnection extends Disposable { +@@ -433,7 +453,7 @@ abstract class PersistentConnection extends Disposable { } // connection was lost, let's try to re-establish it @@ -3948,84 +3952,71 @@ index 94e7e7a4bac154c45078a1b5034e50634a7a43af..8164200dcef1efbc65b50eef9c270af3 this._dirnameKey.set(value ? dirname(value).fsPath : null); this._pathKey.set(value ? value.fsPath : null); diff --git a/src/vs/workbench/contrib/remote/browser/remote.ts b/src/vs/workbench/contrib/remote/browser/remote.ts -index 98573a206f14928fc3fdf18fe927cb75034e4ad1..3ffe27b816e2d0a630985a24dd1af910877c2295 100644 +index 98573a206f14928fc3fdf18fe927cb75034e4ad1..a031f76924abf8f10c510ea9c043f670c5b43074 100644 --- a/src/vs/workbench/contrib/remote/browser/remote.ts +++ b/src/vs/workbench/contrib/remote/browser/remote.ts -@@ -635,7 +635,7 @@ class VisibleProgress { - return this._lastReport; - } - -- constructor(progressService: IProgressService, location: ProgressLocation, initialReport: string | null, buttons: string[], onDidCancel: (choice: number | undefined, lastReport: string | null) => void) { -+ constructor(progressService: IProgressService, location: ProgressLocation, initialReport: string | null, buttons: string[], onDidCancel: (choice: number | undefined, lastReport: string | null) => void, suppressPopup: Boolean | undefined) { - this._isDisposed = false; - this._lastReport = initialReport; - this._currentProgressPromiseResolve = null; -@@ -644,8 +644,10 @@ class VisibleProgress { - - const promise = new Promise((resolve) => this._currentProgressPromiseResolve = resolve); - -+ const options = suppressPopup ? { location: location, buttons: buttons, silent: suppressPopup } : { location: location, buttons: buttons } -+ - progressService.withProgress( -- { location: location, buttons: buttons }, -+ options, - (progress) => { if (!this._isDisposed) { this._currentProgress = progress; } return promise; }, - (choice) => onDidCancel(choice, this._lastReport) - ); -@@ -736,7 +738,7 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution { - let reconnectWaitEvent: ReconnectionWaitEvent | null = null; - let disposableListener: IDisposable | null = null; - -- function showProgress(location: ProgressLocation.Dialog | ProgressLocation.Notification, buttons: { label: string, callback: () => void }[], initialReport: string | null = null): VisibleProgress { -+ function showProgress(location: ProgressLocation.Dialog | ProgressLocation.Notification, buttons: { label: string, callback: () => void }[], initialReport: string | null = null, suppressPopup: Boolean | undefined): VisibleProgress { - if (visibleProgress) { - visibleProgress.dispose(); - visibleProgress = null; -@@ -752,12 +754,12 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution { - buttons[choice].callback(); - } else { - if (location === ProgressLocation.Dialog) { -- visibleProgress = showProgress(ProgressLocation.Notification, buttons, lastReport); -+ visibleProgress = showProgress(ProgressLocation.Notification, buttons, lastReport, suppressPopup); - } else { - hideProgress(); - } - } -- } -+ }, suppressPopup - ); - } - -@@ -796,17 +798,17 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution { +@@ -795,31 +795,43 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution { + } switch (e.type) { case PersistentConnectionEventType.ConnectionLost: - if (!visibleProgress) { +- if (!visibleProgress) { - visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]); -+ visibleProgress = showProgress(ProgressLocation.Notification, [reconnectButton, reloadButton], null, e.suppressPopup); ++ if (e.suppressPopup) { ++ hideProgress() ++ } else { ++ if (!visibleProgress) { ++ visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]); ++ } ++ visibleProgress.report(nls.localize('connectionLost', "Connection Lost")); } - visibleProgress.report(nls.localize('connectionLost', "Connection Lost")); +- visibleProgress.report(nls.localize('connectionLost', "Connection Lost")); break; case PersistentConnectionEventType.ReconnectionWait: reconnectWaitEvent = e; - visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reconnectButton, reloadButton]); -+ visibleProgress = showProgress(lastLocation || ProgressLocation.Dialog, [reconnectButton, reloadButton], null, e.suppressPopup); - visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds); +- visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds); ++ if (e.suppressPopup) { ++ hideProgress() ++ } else { ++ const location = e.forceDialog ? ProgressLocation.Dialog : (lastLocation || ProgressLocation.Notification) ++ visibleProgress = showProgress(location, [reconnectButton, reloadButton]); ++ visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds); ++ } break; case PersistentConnectionEventType.ReconnectionRunning: - visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton]); -+ visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton], null, e.suppressPopup); - visibleProgress.report(nls.localize('reconnectionRunning', "Attempting to reconnect...")); - - // Register to listen for quick input is opened -@@ -815,7 +817,7 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution { - if (contextKeyChangeEvent.affectsSome(reconnectInteraction)) { - // Need to move from dialog if being shown and user needs to type in a prompt - if (lastLocation === ProgressLocation.Dialog && visibleProgress !== null) { +- visibleProgress.report(nls.localize('reconnectionRunning', "Attempting to reconnect...")); +- +- // Register to listen for quick input is opened +- disposableListener = contextKeyService.onDidChangeContext((contextKeyChangeEvent) => { +- const reconnectInteraction = new Set([inQuickPickContextKeyValue]); +- if (contextKeyChangeEvent.affectsSome(reconnectInteraction)) { +- // Need to move from dialog if being shown and user needs to type in a prompt +- if (lastLocation === ProgressLocation.Dialog && visibleProgress !== null) { - visibleProgress = showProgress(ProgressLocation.Notification, [reloadButton], visibleProgress.lastReport); -+ visibleProgress = showProgress(ProgressLocation.Notification, [reloadButton], visibleProgress.lastReport, e.suppressPopup); ++ if (e.suppressPopup) { ++ hideProgress() ++ } else { ++ visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton]); ++ visibleProgress.report(nls.localize('reconnectionRunning', "Attempting to reconnect...")); ++ ++ // Register to listen for quick input is opened ++ disposableListener = contextKeyService.onDidChangeContext((contextKeyChangeEvent) => { ++ const reconnectInteraction = new Set([inQuickPickContextKeyValue]); ++ if (contextKeyChangeEvent.affectsSome(reconnectInteraction)) { ++ // Need to move from dialog if being shown and user needs to type in a prompt ++ if (lastLocation === ProgressLocation.Dialog && visibleProgress !== null) { ++ visibleProgress = showProgress(ProgressLocation.Notification, [reloadButton], visibleProgress.lastReport); ++ } } - } - }); +- } +- }); +- ++ }); ++ } + break; + case PersistentConnectionEventType.ReconnectionPermanentFailure: + hideProgress(); diff --git a/src/vs/workbench/contrib/scm/browser/media/scm.css b/src/vs/workbench/contrib/scm/browser/media/scm.css index 74f6922e98b4bb6a7fb100f5aac015afe9fc171b..3243a97c2d378013d96ffbe87e9df6dd4a66776d 100644 --- a/src/vs/workbench/contrib/scm/browser/media/scm.css From fa0853dca6d335c9643f13c1ffeb5251aba05a70 Mon Sep 17 00:00:00 2001 From: "Machado, Meygha" Date: Tue, 17 Nov 2020 11:15:35 -0600 Subject: [PATCH 5/8] revert reconnect wait times --- ci/dev/vscode.patch | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ci/dev/vscode.patch b/ci/dev/vscode.patch index 2311d318..c8854c8b 100644 --- a/ci/dev/vscode.patch +++ b/ci/dev/vscode.patch @@ -792,11 +792,10 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367 const logPrefix = commonLogPrefix(this._connectionType, this.reconnectionToken, true); this._options.logService.info(`${logPrefix} starting reconnecting loop. You can get more information with the trace log level.`); - this._onDidStateChange.fire(new ConnectionLostEvent()); -- const TIMES = [5, 5, 10, 10, 10, 10, 10, 30]; + let suppressPopup = true; + let forceDialog = false; + this._onDidStateChange.fire(new ConnectionLostEvent(suppressPopup)); -+ const TIMES = [1, 2, 3, 10, 10, 10, 10, 30]; + const TIMES = [5, 5, 10, 10, 10, 10, 10, 30]; + const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt + const disconnectStartTime = Date.now(); From e5067ba2a98cf19f567bafb5356cb7b5f78cf240 Mon Sep 17 00:00:00 2001 From: "Machado, Meygha" Date: Tue, 17 Nov 2020 16:37:43 -0600 Subject: [PATCH 6/8] separate event domain from UI --- ci/dev/vscode.patch | 63 +++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/ci/dev/vscode.patch b/ci/dev/vscode.patch index c8854c8b..c2e58d33 100644 --- a/ci/dev/vscode.patch +++ b/ci/dev/vscode.patch @@ -746,12 +746,12 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367 (err: any, socket: ISocket | undefined) => { if (err || !socket) { options.logService.error(`${logPrefix} socketFactory.connect() failed. Error:`); -@@ -331,12 +331,17 @@ export const enum PersistentConnectionEventType { +@@ -331,12 +331,16 @@ export const enum PersistentConnectionEventType { } export class ConnectionLostEvent { public readonly type = PersistentConnectionEventType.ConnectionLost; + constructor( -+ public readonly suppressPopup?: boolean ++ public readonly connectionAttempt?: number + ) { } } export class ReconnectionWaitEvent { @@ -760,67 +760,68 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367 public readonly durationSeconds: number, - private readonly cancellableTimer: CancelablePromise + private readonly cancellableTimer: CancelablePromise, -+ public readonly suppressPopup?: boolean, -+ public readonly forceDialog?: boolean ++ public readonly connectionAttempt?: number, ) { } public skipWait(): void { -@@ -345,12 +350,21 @@ export class ReconnectionWaitEvent { +@@ -345,12 +349,21 @@ export class ReconnectionWaitEvent { } export class ReconnectionRunningEvent { public readonly type = PersistentConnectionEventType.ReconnectionRunning; + constructor( -+ public readonly suppressPopup?: boolean ++ public readonly connectionAttempt?: number + ) { } } export class ConnectionGainEvent { public readonly type = PersistentConnectionEventType.ConnectionGain; + constructor( -+ public readonly suppressPopup?: boolean ++ public readonly connectionAttempt?: number + ) { } } export class ReconnectionPermanentFailureEvent { public readonly type = PersistentConnectionEventType.ReconnectionPermanentFailure; + constructor( -+ public readonly suppressPopup?: boolean | undefined ++ public readonly connectionAttempt?: number + ) { } } export type PersistenConnectionEvent = ConnectionGainEvent | ConnectionLostEvent | ReconnectionWaitEvent | ReconnectionRunningEvent | ReconnectionPermanentFailureEvent; -@@ -411,16 +425,22 @@ abstract class PersistentConnection extends Disposable { +@@ -411,8 +424,9 @@ abstract class PersistentConnection extends Disposable { } const logPrefix = commonLogPrefix(this._connectionType, this.reconnectionToken, true); this._options.logService.info(`${logPrefix} starting reconnecting loop. You can get more information with the trace log level.`); - this._onDidStateChange.fire(new ConnectionLostEvent()); -+ let suppressPopup = true; -+ let forceDialog = false; -+ this._onDidStateChange.fire(new ConnectionLostEvent(suppressPopup)); ++ this._onDidStateChange.fire(new ConnectionLostEvent(0)); const TIMES = [5, 5, 10, 10, 10, 10, 10, 30]; -+ const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt + const disconnectStartTime = Date.now(); let attempt = -1; do { - attempt++; -+ suppressPopup = (attempt < SHOW_POPUP_ON_ATTEMPT) ? true : false -+ forceDialog = (attempt == SHOW_POPUP_ON_ATTEMPT) +@@ -420,7 +434,7 @@ abstract class PersistentConnection extends Disposable { const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]); try { const sleepPromise = sleep(waitTime); - this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise)); -+ this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise, suppressPopup, forceDialog)); ++ this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise, attempt)); this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`); try { -@@ -433,7 +453,7 @@ abstract class PersistentConnection extends Disposable { +@@ -433,13 +447,13 @@ abstract class PersistentConnection extends Disposable { } // connection was lost, let's try to re-establish it - this._onDidStateChange.fire(new ReconnectionRunningEvent()); -+ this._onDidStateChange.fire(new ReconnectionRunningEvent(suppressPopup)); ++ this._onDidStateChange.fire(new ReconnectionRunningEvent(attempt)); this._options.logService.info(`${logPrefix} resolving connection...`); const simpleOptions = await resolveConnectionOptions(this._options, this.reconnectionToken, this.protocol); this._options.logService.info(`${logPrefix} connecting to ${simpleOptions.host}:${simpleOptions.port}...`); + await connectWithTimeLimit(simpleOptions.logService, this._reconnect(simpleOptions), RECONNECT_TIMEOUT); + this._options.logService.info(`${logPrefix} reconnected!`); +- this._onDidStateChange.fire(new ConnectionGainEvent()); ++ this._onDidStateChange.fire(new ConnectionGainEvent(attempt)); + + break; + } catch (err) { diff --git a/src/vs/platform/storage/browser/storageService.ts b/src/vs/platform/storage/browser/storageService.ts index ab3fd347b69f8a3d9b96e706cd87c911b8ffed6b..9d351037b577f9f1edfd18ae9b3c48a211f4467f 100644 --- a/src/vs/platform/storage/browser/storageService.ts @@ -3951,16 +3952,28 @@ index 94e7e7a4bac154c45078a1b5034e50634a7a43af..8164200dcef1efbc65b50eef9c270af3 this._dirnameKey.set(value ? dirname(value).fsPath : null); this._pathKey.set(value ? value.fsPath : null); diff --git a/src/vs/workbench/contrib/remote/browser/remote.ts b/src/vs/workbench/contrib/remote/browser/remote.ts -index 98573a206f14928fc3fdf18fe927cb75034e4ad1..a031f76924abf8f10c510ea9c043f670c5b43074 100644 +index 98573a206f14928fc3fdf18fe927cb75034e4ad1..1430666aa94f941bda086df503fec8b35aa2b25f 100644 --- a/src/vs/workbench/contrib/remote/browser/remote.ts +++ b/src/vs/workbench/contrib/remote/browser/remote.ts -@@ -795,31 +795,43 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution { +@@ -730,6 +730,7 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution { + @IContextKeyService contextKeyService: IContextKeyService + ) { + const connection = remoteAgentService.getConnection(); ++ const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt + if (connection) { + let visibleProgress: VisibleProgress | null = null; + let lastLocation: ProgressLocation.Dialog | ProgressLocation.Notification | null = null; +@@ -793,33 +794,47 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution { + disposableListener.dispose(); + disposableListener = null; } ++ let suppressPopup = (typeof e.connectionAttempt == 'number' && e.connectionAttempt < SHOW_POPUP_ON_ATTEMPT) ++ let forceDialog = (typeof e.connectionAttempt == 'number' && e.connectionAttempt == SHOW_POPUP_ON_ATTEMPT) switch (e.type) { case PersistentConnectionEventType.ConnectionLost: - if (!visibleProgress) { - visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]); -+ if (e.suppressPopup) { ++ if (suppressPopup) { + hideProgress() + } else { + if (!visibleProgress) { @@ -3974,10 +3987,10 @@ index 98573a206f14928fc3fdf18fe927cb75034e4ad1..a031f76924abf8f10c510ea9c043f670 reconnectWaitEvent = e; - visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reconnectButton, reloadButton]); - visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds); -+ if (e.suppressPopup) { ++ if (suppressPopup) { + hideProgress() + } else { -+ const location = e.forceDialog ? ProgressLocation.Dialog : (lastLocation || ProgressLocation.Notification) ++ const location = forceDialog ? ProgressLocation.Dialog : (lastLocation || ProgressLocation.Notification) + visibleProgress = showProgress(location, [reconnectButton, reloadButton]); + visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds); + } @@ -3993,7 +4006,7 @@ index 98573a206f14928fc3fdf18fe927cb75034e4ad1..a031f76924abf8f10c510ea9c043f670 - // Need to move from dialog if being shown and user needs to type in a prompt - if (lastLocation === ProgressLocation.Dialog && visibleProgress !== null) { - visibleProgress = showProgress(ProgressLocation.Notification, [reloadButton], visibleProgress.lastReport); -+ if (e.suppressPopup) { ++ if (suppressPopup) { + hideProgress() + } else { + visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton]); From 8cb4e2c2268f49a39aa41874839c80d067ed8a2c Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Mon, 30 Nov 2020 13:20:33 -0500 Subject: [PATCH 7/8] vscode: Remove background reconnection fixes from patch I'll have to manually apply as they are not compatible with the latest VS Code after rebase anymore. --- ci/dev/vscode.patch | 154 -------------------------------------------- 1 file changed, 154 deletions(-) diff --git a/ci/dev/vscode.patch b/ci/dev/vscode.patch index c2e58d33..ad613305 100644 --- a/ci/dev/vscode.patch +++ b/ci/dev/vscode.patch @@ -746,82 +746,6 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367 (err: any, socket: ISocket | undefined) => { if (err || !socket) { options.logService.error(`${logPrefix} socketFactory.connect() failed. Error:`); -@@ -331,12 +331,16 @@ export const enum PersistentConnectionEventType { - } - export class ConnectionLostEvent { - public readonly type = PersistentConnectionEventType.ConnectionLost; -+ constructor( -+ public readonly connectionAttempt?: number -+ ) { } - } - export class ReconnectionWaitEvent { - public readonly type = PersistentConnectionEventType.ReconnectionWait; - constructor( - public readonly durationSeconds: number, -- private readonly cancellableTimer: CancelablePromise -+ private readonly cancellableTimer: CancelablePromise, -+ public readonly connectionAttempt?: number, - ) { } - - public skipWait(): void { -@@ -345,12 +349,21 @@ export class ReconnectionWaitEvent { - } - export class ReconnectionRunningEvent { - public readonly type = PersistentConnectionEventType.ReconnectionRunning; -+ constructor( -+ public readonly connectionAttempt?: number -+ ) { } - } - export class ConnectionGainEvent { - public readonly type = PersistentConnectionEventType.ConnectionGain; -+ constructor( -+ public readonly connectionAttempt?: number -+ ) { } - } - export class ReconnectionPermanentFailureEvent { - public readonly type = PersistentConnectionEventType.ReconnectionPermanentFailure; -+ constructor( -+ public readonly connectionAttempt?: number -+ ) { } - } - export type PersistenConnectionEvent = ConnectionGainEvent | ConnectionLostEvent | ReconnectionWaitEvent | ReconnectionRunningEvent | ReconnectionPermanentFailureEvent; - -@@ -411,8 +424,9 @@ abstract class PersistentConnection extends Disposable { - } - const logPrefix = commonLogPrefix(this._connectionType, this.reconnectionToken, true); - this._options.logService.info(`${logPrefix} starting reconnecting loop. You can get more information with the trace log level.`); -- this._onDidStateChange.fire(new ConnectionLostEvent()); -+ this._onDidStateChange.fire(new ConnectionLostEvent(0)); - const TIMES = [5, 5, 10, 10, 10, 10, 10, 30]; -+ - const disconnectStartTime = Date.now(); - let attempt = -1; - do { -@@ -420,7 +434,7 @@ abstract class PersistentConnection extends Disposable { - const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]); - try { - const sleepPromise = sleep(waitTime); -- this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise)); -+ this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise, attempt)); - - this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`); - try { -@@ -433,13 +447,13 @@ abstract class PersistentConnection extends Disposable { - } - - // connection was lost, let's try to re-establish it -- this._onDidStateChange.fire(new ReconnectionRunningEvent()); -+ this._onDidStateChange.fire(new ReconnectionRunningEvent(attempt)); - this._options.logService.info(`${logPrefix} resolving connection...`); - const simpleOptions = await resolveConnectionOptions(this._options, this.reconnectionToken, this.protocol); - this._options.logService.info(`${logPrefix} connecting to ${simpleOptions.host}:${simpleOptions.port}...`); - await connectWithTimeLimit(simpleOptions.logService, this._reconnect(simpleOptions), RECONNECT_TIMEOUT); - this._options.logService.info(`${logPrefix} reconnected!`); -- this._onDidStateChange.fire(new ConnectionGainEvent()); -+ this._onDidStateChange.fire(new ConnectionGainEvent(attempt)); - - break; - } catch (err) { diff --git a/src/vs/platform/storage/browser/storageService.ts b/src/vs/platform/storage/browser/storageService.ts index ab3fd347b69f8a3d9b96e706cd87c911b8ffed6b..9d351037b577f9f1edfd18ae9b3c48a211f4467f 100644 --- a/src/vs/platform/storage/browser/storageService.ts @@ -3951,84 +3875,6 @@ index 94e7e7a4bac154c45078a1b5034e50634a7a43af..8164200dcef1efbc65b50eef9c270af3 this._filenameKey.set(value ? basename(value) : null); this._dirnameKey.set(value ? dirname(value).fsPath : null); this._pathKey.set(value ? value.fsPath : null); -diff --git a/src/vs/workbench/contrib/remote/browser/remote.ts b/src/vs/workbench/contrib/remote/browser/remote.ts -index 98573a206f14928fc3fdf18fe927cb75034e4ad1..1430666aa94f941bda086df503fec8b35aa2b25f 100644 ---- a/src/vs/workbench/contrib/remote/browser/remote.ts -+++ b/src/vs/workbench/contrib/remote/browser/remote.ts -@@ -730,6 +730,7 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution { - @IContextKeyService contextKeyService: IContextKeyService - ) { - const connection = remoteAgentService.getConnection(); -+ const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt - if (connection) { - let visibleProgress: VisibleProgress | null = null; - let lastLocation: ProgressLocation.Dialog | ProgressLocation.Notification | null = null; -@@ -793,33 +794,47 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution { - disposableListener.dispose(); - disposableListener = null; - } -+ let suppressPopup = (typeof e.connectionAttempt == 'number' && e.connectionAttempt < SHOW_POPUP_ON_ATTEMPT) -+ let forceDialog = (typeof e.connectionAttempt == 'number' && e.connectionAttempt == SHOW_POPUP_ON_ATTEMPT) - switch (e.type) { - case PersistentConnectionEventType.ConnectionLost: -- if (!visibleProgress) { -- visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]); -+ if (suppressPopup) { -+ hideProgress() -+ } else { -+ if (!visibleProgress) { -+ visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]); -+ } -+ visibleProgress.report(nls.localize('connectionLost', "Connection Lost")); - } -- visibleProgress.report(nls.localize('connectionLost', "Connection Lost")); - break; - case PersistentConnectionEventType.ReconnectionWait: - reconnectWaitEvent = e; -- visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reconnectButton, reloadButton]); -- visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds); -+ if (suppressPopup) { -+ hideProgress() -+ } else { -+ const location = forceDialog ? ProgressLocation.Dialog : (lastLocation || ProgressLocation.Notification) -+ visibleProgress = showProgress(location, [reconnectButton, reloadButton]); -+ visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds); -+ } - break; - case PersistentConnectionEventType.ReconnectionRunning: -- visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton]); -- visibleProgress.report(nls.localize('reconnectionRunning', "Attempting to reconnect...")); -- -- // Register to listen for quick input is opened -- disposableListener = contextKeyService.onDidChangeContext((contextKeyChangeEvent) => { -- const reconnectInteraction = new Set([inQuickPickContextKeyValue]); -- if (contextKeyChangeEvent.affectsSome(reconnectInteraction)) { -- // Need to move from dialog if being shown and user needs to type in a prompt -- if (lastLocation === ProgressLocation.Dialog && visibleProgress !== null) { -- visibleProgress = showProgress(ProgressLocation.Notification, [reloadButton], visibleProgress.lastReport); -+ if (suppressPopup) { -+ hideProgress() -+ } else { -+ visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton]); -+ visibleProgress.report(nls.localize('reconnectionRunning', "Attempting to reconnect...")); -+ -+ // Register to listen for quick input is opened -+ disposableListener = contextKeyService.onDidChangeContext((contextKeyChangeEvent) => { -+ const reconnectInteraction = new Set([inQuickPickContextKeyValue]); -+ if (contextKeyChangeEvent.affectsSome(reconnectInteraction)) { -+ // Need to move from dialog if being shown and user needs to type in a prompt -+ if (lastLocation === ProgressLocation.Dialog && visibleProgress !== null) { -+ visibleProgress = showProgress(ProgressLocation.Notification, [reloadButton], visibleProgress.lastReport); -+ } - } -- } -- }); -- -+ }); -+ } - break; - case PersistentConnectionEventType.ReconnectionPermanentFailure: - hideProgress(); diff --git a/src/vs/workbench/contrib/scm/browser/media/scm.css b/src/vs/workbench/contrib/scm/browser/media/scm.css index 74f6922e98b4bb6a7fb100f5aac015afe9fc171b..3243a97c2d378013d96ffbe87e9df6dd4a66776d 100644 --- a/src/vs/workbench/contrib/scm/browser/media/scm.css From c35d558352273f4b34b2bf7fa454dc2aeb92cbe3 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Mon, 30 Nov 2020 13:23:17 -0500 Subject: [PATCH 8/8] vscode: Reconnect in the background up to 5 seconds Based on the previous commits by @mgmachado but simplified. I also changed the threshold to error after a single attempt as the connection has likely been borked and the user should be in the know if they couldn't reconnect after 5 seconds. Closes #1791 --- ci/dev/vscode.patch | 58 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/ci/dev/vscode.patch b/ci/dev/vscode.patch index ad613305..ed83c523 100644 --- a/ci/dev/vscode.patch +++ b/ci/dev/vscode.patch @@ -734,7 +734,7 @@ index 3715cbb8e6ee41c3d9b5090918d243b723ae2d00..c65de8ad37e727d66da97a8f8b170cbc - - diff --git a/src/vs/platform/remote/common/remoteAgentConnection.ts b/src/vs/platform/remote/common/remoteAgentConnection.ts -index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367c3207fe8 100644 +index fdd5890c69f72025b94913380f0d226226e8c8fb..957b4812783f6b1d97d1003c63725f541042059f 100644 --- a/src/vs/platform/remote/common/remoteAgentConnection.ts +++ b/src/vs/platform/remote/common/remoteAgentConnection.ts @@ -93,7 +93,7 @@ async function connectToRemoteExtensionHostAgent(options: ISimpleConnectionOptio @@ -746,6 +746,25 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367 (err: any, socket: ISocket | undefined) => { if (err || !socket) { options.logService.error(`${logPrefix} socketFactory.connect() failed. Error:`); +@@ -338,7 +338,8 @@ export class ReconnectionWaitEvent { + public readonly type = PersistentConnectionEventType.ReconnectionWait; + constructor( + public readonly durationSeconds: number, +- private readonly cancellableTimer: CancelablePromise ++ private readonly cancellableTimer: CancelablePromise, ++ public readonly connectionAttempt: number + ) { } + + public skipWait(): void { +@@ -422,7 +423,7 @@ abstract class PersistentConnection extends Disposable { + const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]); + try { + const sleepPromise = sleep(waitTime); +- this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise)); ++ this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise, attempt+1)); + + this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`); + try { diff --git a/src/vs/platform/storage/browser/storageService.ts b/src/vs/platform/storage/browser/storageService.ts index ab3fd347b69f8a3d9b96e706cd87c911b8ffed6b..9d351037b577f9f1edfd18ae9b3c48a211f4467f 100644 --- a/src/vs/platform/storage/browser/storageService.ts @@ -3875,6 +3894,43 @@ index 94e7e7a4bac154c45078a1b5034e50634a7a43af..8164200dcef1efbc65b50eef9c270af3 this._filenameKey.set(value ? basename(value) : null); this._dirnameKey.set(value ? dirname(value).fsPath : null); this._pathKey.set(value ? value.fsPath : null); +diff --git a/src/vs/workbench/contrib/remote/browser/remote.ts b/src/vs/workbench/contrib/remote/browser/remote.ts +index c6d98b601a3b6966e8a99d2c05b3b7f02b08e6ca..c2a76fbd75d24d509f312cb8bf094eb297374f04 100644 +--- a/src/vs/workbench/contrib/remote/browser/remote.ts ++++ b/src/vs/workbench/contrib/remote/browser/remote.ts +@@ -778,17 +778,30 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution { + } + switch (e.type) { + case PersistentConnectionEventType.ConnectionLost: ++ break; ++ case PersistentConnectionEventType.ReconnectionWait: ++ const BACKGROUND_RECONNECT_THRESHOLD = 2; ++ // If the first reconnect fails, we show the popup. ++ // This corresponds to about 5s wait. ++ if (e.connectionAttempt < BACKGROUND_RECONNECT_THRESHOLD) { ++ break; ++ } ++ + if (!visibleProgress) { + visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]); + } + visibleProgress.report(nls.localize('connectionLost', "Connection Lost")); +- break; +- case PersistentConnectionEventType.ReconnectionWait: ++ + reconnectWaitEvent = e; + visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reconnectButton, reloadButton]); + visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds); + break; + case PersistentConnectionEventType.ReconnectionRunning: ++ if (!visibleProgress) { ++ // Our background reconnection threshold hasn't been hit yet. ++ break; ++ } ++ + visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton]); + visibleProgress.report(nls.localize('reconnectionRunning', "Attempting to reconnect...")); + diff --git a/src/vs/workbench/contrib/scm/browser/media/scm.css b/src/vs/workbench/contrib/scm/browser/media/scm.css index 74f6922e98b4bb6a7fb100f5aac015afe9fc171b..3243a97c2d378013d96ffbe87e9df6dd4a66776d 100644 --- a/src/vs/workbench/contrib/scm/browser/media/scm.css