Skip to content

Commit e5067ba

Browse files
mgmachadonhooyr
authored andcommitted
separate event domain from UI
1 parent fa0853d commit e5067ba

File tree

1 file changed

+38
-25
lines changed

1 file changed

+38
-25
lines changed

ci/dev/vscode.patch

+38-25
Original file line numberDiff line numberDiff line change
@@ -746,12 +746,12 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367
746746
(err: any, socket: ISocket | undefined) => {
747747
if (err || !socket) {
748748
options.logService.error(`${logPrefix} socketFactory.connect() failed. Error:`);
749-
@@ -331,12 +331,17 @@ export const enum PersistentConnectionEventType {
749+
@@ -331,12 +331,16 @@ export const enum PersistentConnectionEventType {
750750
}
751751
export class ConnectionLostEvent {
752752
public readonly type = PersistentConnectionEventType.ConnectionLost;
753753
+ constructor(
754-
+ public readonly suppressPopup?: boolean
754+
+ public readonly connectionAttempt?: number
755755
+ ) { }
756756
}
757757
export class ReconnectionWaitEvent {
@@ -760,67 +760,68 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367
760760
public readonly durationSeconds: number,
761761
- private readonly cancellableTimer: CancelablePromise<void>
762762
+ private readonly cancellableTimer: CancelablePromise<void>,
763-
+ public readonly suppressPopup?: boolean,
764-
+ public readonly forceDialog?: boolean
763+
+ public readonly connectionAttempt?: number,
765764
) { }
766765

767766
public skipWait(): void {
768-
@@ -345,12 +350,21 @@ export class ReconnectionWaitEvent {
767+
@@ -345,12 +349,21 @@ export class ReconnectionWaitEvent {
769768
}
770769
export class ReconnectionRunningEvent {
771770
public readonly type = PersistentConnectionEventType.ReconnectionRunning;
772771
+ constructor(
773-
+ public readonly suppressPopup?: boolean
772+
+ public readonly connectionAttempt?: number
774773
+ ) { }
775774
}
776775
export class ConnectionGainEvent {
777776
public readonly type = PersistentConnectionEventType.ConnectionGain;
778777
+ constructor(
779-
+ public readonly suppressPopup?: boolean
778+
+ public readonly connectionAttempt?: number
780779
+ ) { }
781780
}
782781
export class ReconnectionPermanentFailureEvent {
783782
public readonly type = PersistentConnectionEventType.ReconnectionPermanentFailure;
784783
+ constructor(
785-
+ public readonly suppressPopup?: boolean | undefined
784+
+ public readonly connectionAttempt?: number
786785
+ ) { }
787786
}
788787
export type PersistenConnectionEvent = ConnectionGainEvent | ConnectionLostEvent | ReconnectionWaitEvent | ReconnectionRunningEvent | ReconnectionPermanentFailureEvent;
789788

790-
@@ -411,16 +425,22 @@ abstract class PersistentConnection extends Disposable {
789+
@@ -411,8 +424,9 @@ abstract class PersistentConnection extends Disposable {
791790
}
792791
const logPrefix = commonLogPrefix(this._connectionType, this.reconnectionToken, true);
793792
this._options.logService.info(`${logPrefix} starting reconnecting loop. You can get more information with the trace log level.`);
794793
- this._onDidStateChange.fire(new ConnectionLostEvent());
795-
+ let suppressPopup = true;
796-
+ let forceDialog = false;
797-
+ this._onDidStateChange.fire(new ConnectionLostEvent(suppressPopup));
794+
+ this._onDidStateChange.fire(new ConnectionLostEvent(0));
798795
const TIMES = [5, 5, 10, 10, 10, 10, 10, 30];
799-
+ const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt
800796
+
801797
const disconnectStartTime = Date.now();
802798
let attempt = -1;
803799
do {
804-
attempt++;
805-
+ suppressPopup = (attempt < SHOW_POPUP_ON_ATTEMPT) ? true : false
806-
+ forceDialog = (attempt == SHOW_POPUP_ON_ATTEMPT)
800+
@@ -420,7 +434,7 @@ abstract class PersistentConnection extends Disposable {
807801
const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]);
808802
try {
809803
const sleepPromise = sleep(waitTime);
810804
- this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise));
811-
+ this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise, suppressPopup, forceDialog));
805+
+ this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise, attempt));
812806

813807
this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`);
814808
try {
815-
@@ -433,7 +453,7 @@ abstract class PersistentConnection extends Disposable {
809+
@@ -433,13 +447,13 @@ abstract class PersistentConnection extends Disposable {
816810
}
817811

818812
// connection was lost, let's try to re-establish it
819813
- this._onDidStateChange.fire(new ReconnectionRunningEvent());
820-
+ this._onDidStateChange.fire(new ReconnectionRunningEvent(suppressPopup));
814+
+ this._onDidStateChange.fire(new ReconnectionRunningEvent(attempt));
821815
this._options.logService.info(`${logPrefix} resolving connection...`);
822816
const simpleOptions = await resolveConnectionOptions(this._options, this.reconnectionToken, this.protocol);
823817
this._options.logService.info(`${logPrefix} connecting to ${simpleOptions.host}:${simpleOptions.port}...`);
818+
await connectWithTimeLimit(simpleOptions.logService, this._reconnect(simpleOptions), RECONNECT_TIMEOUT);
819+
this._options.logService.info(`${logPrefix} reconnected!`);
820+
- this._onDidStateChange.fire(new ConnectionGainEvent());
821+
+ this._onDidStateChange.fire(new ConnectionGainEvent(attempt));
822+
823+
break;
824+
} catch (err) {
824825
diff --git a/src/vs/platform/storage/browser/storageService.ts b/src/vs/platform/storage/browser/storageService.ts
825826
index ab3fd347b69f8a3d9b96e706cd87c911b8ffed6b..9d351037b577f9f1edfd18ae9b3c48a211f4467f 100644
826827
--- a/src/vs/platform/storage/browser/storageService.ts
@@ -3951,16 +3952,28 @@ index 94e7e7a4bac154c45078a1b5034e50634a7a43af..8164200dcef1efbc65b50eef9c270af3
39513952
this._dirnameKey.set(value ? dirname(value).fsPath : null);
39523953
this._pathKey.set(value ? value.fsPath : null);
39533954
diff --git a/src/vs/workbench/contrib/remote/browser/remote.ts b/src/vs/workbench/contrib/remote/browser/remote.ts
3954-
index 98573a206f14928fc3fdf18fe927cb75034e4ad1..a031f76924abf8f10c510ea9c043f670c5b43074 100644
3955+
index 98573a206f14928fc3fdf18fe927cb75034e4ad1..1430666aa94f941bda086df503fec8b35aa2b25f 100644
39553956
--- a/src/vs/workbench/contrib/remote/browser/remote.ts
39563957
+++ b/src/vs/workbench/contrib/remote/browser/remote.ts
3957-
@@ -795,31 +795,43 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
3958+
@@ -730,6 +730,7 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
3959+
@IContextKeyService contextKeyService: IContextKeyService
3960+
) {
3961+
const connection = remoteAgentService.getConnection();
3962+
+ const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt
3963+
if (connection) {
3964+
let visibleProgress: VisibleProgress | null = null;
3965+
let lastLocation: ProgressLocation.Dialog | ProgressLocation.Notification | null = null;
3966+
@@ -793,33 +794,47 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
3967+
disposableListener.dispose();
3968+
disposableListener = null;
39583969
}
3970+
+ let suppressPopup = (typeof e.connectionAttempt == 'number' && e.connectionAttempt < SHOW_POPUP_ON_ATTEMPT)
3971+
+ let forceDialog = (typeof e.connectionAttempt == 'number' && e.connectionAttempt == SHOW_POPUP_ON_ATTEMPT)
39593972
switch (e.type) {
39603973
case PersistentConnectionEventType.ConnectionLost:
39613974
- if (!visibleProgress) {
39623975
- visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]);
3963-
+ if (e.suppressPopup) {
3976+
+ if (suppressPopup) {
39643977
+ hideProgress()
39653978
+ } else {
39663979
+ if (!visibleProgress) {
@@ -3974,10 +3987,10 @@ index 98573a206f14928fc3fdf18fe927cb75034e4ad1..a031f76924abf8f10c510ea9c043f670
39743987
reconnectWaitEvent = e;
39753988
- visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reconnectButton, reloadButton]);
39763989
- visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds);
3977-
+ if (e.suppressPopup) {
3990+
+ if (suppressPopup) {
39783991
+ hideProgress()
39793992
+ } else {
3980-
+ const location = e.forceDialog ? ProgressLocation.Dialog : (lastLocation || ProgressLocation.Notification)
3993+
+ const location = forceDialog ? ProgressLocation.Dialog : (lastLocation || ProgressLocation.Notification)
39813994
+ visibleProgress = showProgress(location, [reconnectButton, reloadButton]);
39823995
+ visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds);
39833996
+ }
@@ -3993,7 +4006,7 @@ index 98573a206f14928fc3fdf18fe927cb75034e4ad1..a031f76924abf8f10c510ea9c043f670
39934006
- // Need to move from dialog if being shown and user needs to type in a prompt
39944007
- if (lastLocation === ProgressLocation.Dialog && visibleProgress !== null) {
39954008
- visibleProgress = showProgress(ProgressLocation.Notification, [reloadButton], visibleProgress.lastReport);
3996-
+ if (e.suppressPopup) {
4009+
+ if (suppressPopup) {
39974010
+ hideProgress()
39984011
+ } else {
39994012
+ visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton]);

0 commit comments

Comments
 (0)