solution with forceDialog for attempt 3 and no change to VisibleProgress class

This commit is contained in:
Machado, Meygha 2020-11-17 10:58:25 -06:00 committed by Anmol Sethi
parent 4eb4375119
commit a898dd34b9
No known key found for this signature in database
GPG Key ID: 8CEF1878FF10ADEB
1 changed files with 61 additions and 70 deletions

View File

@ -746,7 +746,7 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367
(err: any, socket: ISocket | undefined) => { (err: any, socket: ISocket | undefined) => {
if (err || !socket) { if (err || !socket) {
options.logService.error(`${logPrefix} socketFactory.connect() failed. Error:`); 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 { export class ConnectionLostEvent {
public readonly type = PersistentConnectionEventType.ConnectionLost; public readonly type = PersistentConnectionEventType.ConnectionLost;
@ -760,11 +760,12 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367
public readonly durationSeconds: number, public readonly durationSeconds: number,
- private readonly cancellableTimer: CancelablePromise<void> - private readonly cancellableTimer: CancelablePromise<void>
+ private readonly cancellableTimer: CancelablePromise<void>, + private readonly cancellableTimer: CancelablePromise<void>,
+ public readonly suppressPopup?: boolean + public readonly suppressPopup?: boolean,
+ public readonly forceDialog?: boolean
) { } ) { }
public skipWait(): void { public skipWait(): void {
@@ -345,12 +349,21 @@ export class ReconnectionWaitEvent { @@ -345,12 +350,21 @@ export class ReconnectionWaitEvent {
} }
export class ReconnectionRunningEvent { export class ReconnectionRunningEvent {
public readonly type = PersistentConnectionEventType.ReconnectionRunning; public readonly type = PersistentConnectionEventType.ReconnectionRunning;
@ -786,14 +787,16 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367
} }
export type PersistenConnectionEvent = ConnectionGainEvent | ConnectionLostEvent | ReconnectionWaitEvent | ReconnectionRunningEvent | ReconnectionPermanentFailureEvent; 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); 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._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];
+ let suppressPopup = true; + let suppressPopup = true;
+ let forceDialog = false;
+ this._onDidStateChange.fire(new ConnectionLostEvent(suppressPopup)); + 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 SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt
+ +
const disconnectStartTime = Date.now(); const disconnectStartTime = Date.now();
@ -801,15 +804,16 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367
do { do {
attempt++; attempt++;
+ suppressPopup = (attempt < SHOW_POPUP_ON_ATTEMPT) ? true : false + 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]); const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]);
try { try {
const sleepPromise = sleep(waitTime); const sleepPromise = sleep(waitTime);
- this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise)); - 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...`); this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`);
try { 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 // 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._dirnameKey.set(value ? dirname(value).fsPath : null);
this._pathKey.set(value ? 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 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 --- a/src/vs/workbench/contrib/remote/browser/remote.ts
+++ b/src/vs/workbench/contrib/remote/browser/remote.ts +++ b/src/vs/workbench/contrib/remote/browser/remote.ts
@@ -635,7 +635,7 @@ class VisibleProgress { @@ -795,31 +795,43 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
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<void>((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) { switch (e.type) {
case PersistentConnectionEventType.ConnectionLost: case PersistentConnectionEventType.ConnectionLost:
if (!visibleProgress) { - if (!visibleProgress) {
- visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]); - 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; break;
case PersistentConnectionEventType.ReconnectionWait: case PersistentConnectionEventType.ReconnectionWait:
reconnectWaitEvent = e; reconnectWaitEvent = e;
- visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reconnectButton, reloadButton]); - 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; break;
case PersistentConnectionEventType.ReconnectionRunning: case PersistentConnectionEventType.ReconnectionRunning:
- visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton]); - visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton]);
+ visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton], null, e.suppressPopup); - visibleProgress.report(nls.localize('reconnectionRunning', "Attempting to reconnect..."));
visibleProgress.report(nls.localize('reconnectionRunning', "Attempting to reconnect...")); -
- // Register to listen for quick input is opened
// Register to listen for quick input is opened - disposableListener = contextKeyService.onDidChangeContext((contextKeyChangeEvent) => {
@@ -815,7 +817,7 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution { - const reconnectInteraction = new Set<string>([inQuickPickContextKeyValue]);
if (contextKeyChangeEvent.affectsSome(reconnectInteraction)) { - if (contextKeyChangeEvent.affectsSome(reconnectInteraction)) {
// Need to move from dialog if being shown and user needs to type in a prompt - // Need to move from dialog if being shown and user needs to type in a prompt
if (lastLocation === ProgressLocation.Dialog && visibleProgress !== null) { - if (lastLocation === ProgressLocation.Dialog && visibleProgress !== null) {
- visibleProgress = showProgress(ProgressLocation.Notification, [reloadButton], visibleProgress.lastReport); - 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<string>([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 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 index 74f6922e98b4bb6a7fb100f5aac015afe9fc171b..3243a97c2d378013d96ffbe87e9df6dd4a66776d 100644
--- a/src/vs/workbench/contrib/scm/browser/media/scm.css --- a/src/vs/workbench/contrib/scm/browser/media/scm.css