Skip to content

Commit 43ff3cf

Browse files
committed
one working solution without event suppression
1 parent ac7b11e commit 43ff3cf

File tree

1 file changed

+137
-14
lines changed

1 file changed

+137
-14
lines changed

ci/dev/vscode.patch

+137-14
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ index 3715cbb8e6ee41c3d9b5090918d243b723ae2d00..c65de8ad37e727d66da97a8f8b170cbc
689689
-
690690
-
691691
diff --git a/src/vs/platform/remote/common/remoteAgentConnection.ts b/src/vs/platform/remote/common/remoteAgentConnection.ts
692-
index 18d3d04fd20335975293e37b3b641120dd92da20..48ba6434bd5fbd96919b1e109f350016b97aadc0 100644
692+
index 18d3d04fd20335975293e37b3b641120dd92da20..ddc85643fc414991bf885f099f982d9de1b9eae2 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,15 +701,78 @@ index 18d3d04fd20335975293e37b3b641120dd92da20..48ba6434bd5fbd96919b1e109f350016
701701
(err: any, socket: ISocket | undefined) => {
702702
if (err || !socket) {
703703
options.logService.error(`${logPrefix} socketFactory.connect() failed. Error:`);
704-
@@ -413,6 +413,8 @@ abstract class PersistentConnection extends Disposable {
704+
@@ -331,12 +331,16 @@ export const enum PersistentConnectionEventType {
705+
}
706+
export class ConnectionLostEvent {
707+
public readonly type = PersistentConnectionEventType.ConnectionLost;
708+
+ constructor(
709+
+ public readonly suppressPopup?: boolean
710+
+ ) { }
711+
}
712+
export class ReconnectionWaitEvent {
713+
public readonly type = PersistentConnectionEventType.ReconnectionWait;
714+
constructor(
715+
public readonly durationSeconds: number,
716+
- private readonly cancellableTimer: CancelablePromise<void>
717+
+ private readonly cancellableTimer: CancelablePromise<void>,
718+
+ public readonly suppressPopup?: boolean
719+
) { }
720+
721+
public skipWait(): void {
722+
@@ -345,12 +349,21 @@ export class ReconnectionWaitEvent {
723+
}
724+
export class ReconnectionRunningEvent {
725+
public readonly type = PersistentConnectionEventType.ReconnectionRunning;
726+
+ constructor(
727+
+ public readonly suppressPopup?: boolean
728+
+ ) { }
729+
}
730+
export class ConnectionGainEvent {
731+
public readonly type = PersistentConnectionEventType.ConnectionGain;
732+
+ constructor(
733+
+ public readonly suppressPopup?: boolean
734+
+ ) { }
735+
}
736+
export class ReconnectionPermanentFailureEvent {
737+
public readonly type = PersistentConnectionEventType.ReconnectionPermanentFailure;
738+
+ constructor(
739+
+ public readonly suppressPopup?: boolean | undefined
740+
+ ) { }
741+
}
742+
export type PersistenConnectionEvent = ConnectionGainEvent | ConnectionLostEvent | ReconnectionWaitEvent | ReconnectionRunningEvent | ReconnectionPermanentFailureEvent;
743+
744+
@@ -411,16 +424,20 @@ abstract class PersistentConnection extends Disposable {
745+
}
746+
const logPrefix = commonLogPrefix(this._connectionType, this.reconnectionToken, true);
705747
this._options.logService.info(`${logPrefix} starting reconnecting loop. You can get more information with the trace log level.`);
706-
this._onDidStateChange.fire(new ConnectionLostEvent());
748+
- this._onDidStateChange.fire(new ConnectionLostEvent());
749+
+ let suppressPopup = true;
750+
+ this._onDidStateChange.fire(new ConnectionLostEvent(suppressPopup));
707751
const TIMES = [5, 5, 10, 10, 10, 10, 10, 30];
708-
+ // const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt
752+
+ const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt
709753
+
710754
const disconnectStartTime = Date.now();
711755
let attempt = -1;
712756
do {
757+
attempt++;
758+
+ suppressPopup = (attempt < SHOW_POPUP_ON_ATTEMPT) ? true : false
759+
const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]);
760+
try {
761+
const sleepPromise = sleep(waitTime);
762+
- this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise));
763+
+ this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise, suppressPopup));
764+
765+
this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`);
766+
try {
767+
@@ -433,7 +450,7 @@ abstract class PersistentConnection extends Disposable {
768+
}
769+
770+
// connection was lost, let's try to re-establish it
771+
- this._onDidStateChange.fire(new ReconnectionRunningEvent());
772+
+ this._onDidStateChange.fire(new ReconnectionRunningEvent(suppressPopup));
773+
this._options.logService.info(`${logPrefix} resolving connection...`);
774+
const simpleOptions = await resolveConnectionOptions(this._options, this.reconnectionToken, this.protocol);
775+
this._options.logService.info(`${logPrefix} connecting to ${simpleOptions.host}:${simpleOptions.port}...`);
713776
diff --git a/src/vs/platform/storage/browser/storageService.ts b/src/vs/platform/storage/browser/storageService.ts
714777
index ab3fd347b69f8a3d9b96e706cd87c911b8ffed6b..9d351037b577f9f1edfd18ae9b3c48a211f4467f 100644
715778
--- a/src/vs/platform/storage/browser/storageService.ts
@@ -3209,24 +3272,84 @@ index 94e7e7a4bac154c45078a1b5034e50634a7a43af..8164200dcef1efbc65b50eef9c270af3
32093272
this._dirnameKey.set(value ? dirname(value).fsPath : null);
32103273
this._pathKey.set(value ? value.fsPath : null);
32113274
diff --git a/src/vs/workbench/contrib/remote/browser/remote.ts b/src/vs/workbench/contrib/remote/browser/remote.ts
3212-
index 98573a206f14928fc3fdf18fe927cb75034e4ad1..2f6a2fd6733e286024d20530773e3fbc26ffe16c 100644
3275+
index 98573a206f14928fc3fdf18fe927cb75034e4ad1..3ffe27b816e2d0a630985a24dd1af910877c2295 100644
32133276
--- a/src/vs/workbench/contrib/remote/browser/remote.ts
32143277
+++ b/src/vs/workbench/contrib/remote/browser/remote.ts
3215-
@@ -795,10 +795,10 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
3216-
}
3278+
@@ -635,7 +635,7 @@ class VisibleProgress {
3279+
return this._lastReport;
3280+
}
3281+
3282+
- constructor(progressService: IProgressService, location: ProgressLocation, initialReport: string | null, buttons: string[], onDidCancel: (choice: number | undefined, lastReport: string | null) => void) {
3283+
+ constructor(progressService: IProgressService, location: ProgressLocation, initialReport: string | null, buttons: string[], onDidCancel: (choice: number | undefined, lastReport: string | null) => void, suppressPopup: Boolean | undefined) {
3284+
this._isDisposed = false;
3285+
this._lastReport = initialReport;
3286+
this._currentProgressPromiseResolve = null;
3287+
@@ -644,8 +644,10 @@ class VisibleProgress {
3288+
3289+
const promise = new Promise<void>((resolve) => this._currentProgressPromiseResolve = resolve);
3290+
3291+
+ const options = suppressPopup ? { location: location, buttons: buttons, silent: suppressPopup } : { location: location, buttons: buttons }
3292+
+
3293+
progressService.withProgress(
3294+
- { location: location, buttons: buttons },
3295+
+ options,
3296+
(progress) => { if (!this._isDisposed) { this._currentProgress = progress; } return promise; },
3297+
(choice) => onDidCancel(choice, this._lastReport)
3298+
);
3299+
@@ -736,7 +738,7 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
3300+
let reconnectWaitEvent: ReconnectionWaitEvent | null = null;
3301+
let disposableListener: IDisposable | null = null;
3302+
3303+
- function showProgress(location: ProgressLocation.Dialog | ProgressLocation.Notification, buttons: { label: string, callback: () => void }[], initialReport: string | null = null): VisibleProgress {
3304+
+ function showProgress(location: ProgressLocation.Dialog | ProgressLocation.Notification, buttons: { label: string, callback: () => void }[], initialReport: string | null = null, suppressPopup: Boolean | undefined): VisibleProgress {
3305+
if (visibleProgress) {
3306+
visibleProgress.dispose();
3307+
visibleProgress = null;
3308+
@@ -752,12 +754,12 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
3309+
buttons[choice].callback();
3310+
} else {
3311+
if (location === ProgressLocation.Dialog) {
3312+
- visibleProgress = showProgress(ProgressLocation.Notification, buttons, lastReport);
3313+
+ visibleProgress = showProgress(ProgressLocation.Notification, buttons, lastReport, suppressPopup);
3314+
} else {
3315+
hideProgress();
3316+
}
3317+
}
3318+
- }
3319+
+ }, suppressPopup
3320+
);
3321+
}
3322+
3323+
@@ -796,17 +798,17 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
32173324
switch (e.type) {
32183325
case PersistentConnectionEventType.ConnectionLost:
3219-
- if (!visibleProgress) {
3326+
if (!visibleProgress) {
32203327
- visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]);
3221-
- }
3222-
- visibleProgress.report(nls.localize('connectionLost', "Connection Lost"));
3223-
+ // if (!visibleProgress) {
3224-
+ // visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]);
3225-
+ // }
3226-
+ // visibleProgress.report(nls.localize('connectionLost', "Connection Lost"));
3328+
+ visibleProgress = showProgress(ProgressLocation.Notification, [reconnectButton, reloadButton], null, e.suppressPopup);
3329+
}
3330+
visibleProgress.report(nls.localize('connectionLost', "Connection Lost"));
32273331
break;
32283332
case PersistentConnectionEventType.ReconnectionWait:
32293333
reconnectWaitEvent = e;
3334+
- visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reconnectButton, reloadButton]);
3335+
+ visibleProgress = showProgress(lastLocation || ProgressLocation.Dialog, [reconnectButton, reloadButton], null, e.suppressPopup);
3336+
visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds);
3337+
break;
3338+
case PersistentConnectionEventType.ReconnectionRunning:
3339+
- visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton]);
3340+
+ visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton], null, e.suppressPopup);
3341+
visibleProgress.report(nls.localize('reconnectionRunning', "Attempting to reconnect..."));
3342+
3343+
// Register to listen for quick input is opened
3344+
@@ -815,7 +817,7 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
3345+
if (contextKeyChangeEvent.affectsSome(reconnectInteraction)) {
3346+
// Need to move from dialog if being shown and user needs to type in a prompt
3347+
if (lastLocation === ProgressLocation.Dialog && visibleProgress !== null) {
3348+
- visibleProgress = showProgress(ProgressLocation.Notification, [reloadButton], visibleProgress.lastReport);
3349+
+ visibleProgress = showProgress(ProgressLocation.Notification, [reloadButton], visibleProgress.lastReport, e.suppressPopup);
3350+
}
3351+
}
3352+
});
32303353
diff --git a/src/vs/workbench/contrib/scm/browser/media/scm.css b/src/vs/workbench/contrib/scm/browser/media/scm.css
32313354
index ac44ad3bae428def66e22fe9cc1c54648d429f6b..faa63023c4c586b51fa3c2a48ff3641b9cb0e145 100644
32323355
--- a/src/vs/workbench/contrib/scm/browser/media/scm.css

0 commit comments

Comments
 (0)