mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Polish cloud changes progress notification (#169307)
This commit is contained in:
parent
3fcbb1cc96
commit
e95094cdfd
|
@ -18,7 +18,7 @@ import { URI } from 'vs/base/common/uri';
|
|||
import { basename, joinPath, relativePath } from 'vs/base/common/resources';
|
||||
import { encodeBase64 } from 'vs/base/common/buffer';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IProgressService, ProgressLocation } from 'vs/platform/progress/common/progress';
|
||||
import { IProgress, IProgressService, IProgressStep, ProgressLocation } from 'vs/platform/progress/common/progress';
|
||||
import { EditSessionsWorkbenchService } from 'vs/workbench/contrib/editSessions/browser/editSessionsStorageService';
|
||||
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { UserDataSyncErrorCode, UserDataSyncStoreError } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
|
@ -60,6 +60,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
|
|||
import { ILocalizedString } from 'vs/platform/action/common/action';
|
||||
import { Codicon } from 'vs/base/common/codicons';
|
||||
import { CancellationError } from 'vs/base/common/errors';
|
||||
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
|
||||
|
||||
registerSingleton(IEditSessionsLogService, EditSessionsLogService, InstantiationType.Delayed);
|
||||
registerSingleton(IEditSessionsStorageService, EditSessionsWorkbenchService, InstantiationType.Delayed);
|
||||
|
@ -81,10 +82,10 @@ const showOutputChannelCommand: IAction2Options = {
|
|||
title: { value: localize('show log', 'Show Log'), original: 'Show Log' },
|
||||
category: EDIT_SESSION_SYNC_CATEGORY
|
||||
};
|
||||
const resumingProgressOptions = {
|
||||
const resumeProgressOptionsTitle = `[${localize('resuming working changes window', 'Resuming working changes...')}](command:${showOutputChannelCommand.id})`;
|
||||
const resumeProgressOptions = {
|
||||
location: ProgressLocation.Window,
|
||||
type: 'syncing',
|
||||
title: `[${localize('resuming working changes window', 'Resuming working changes...')}](command:${showOutputChannelCommand.id})`
|
||||
};
|
||||
const queryParamName = 'editSessionId';
|
||||
|
||||
|
@ -122,6 +123,7 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
|
|||
@IStorageService private readonly storageService: IStorageService,
|
||||
@IActivityService private readonly activityService: IActivityService,
|
||||
@IEditorService private readonly editorService: IEditorService,
|
||||
@IRemoteAgentService private readonly remoteAgentService: IRemoteAgentService,
|
||||
) {
|
||||
super();
|
||||
|
||||
|
@ -144,13 +146,13 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
|
|||
|
||||
if (this.environmentService.editSessionId !== undefined) {
|
||||
this.logService.info(`Resuming cloud changes, reason: found editSessionId ${this.environmentService.editSessionId} in environment service...`);
|
||||
await this.progressService.withProgress(resumingProgressOptions, async () => await this.resumeEditSession(this.environmentService.editSessionId).finally(() => this.environmentService.editSessionId = undefined));
|
||||
await this.progressService.withProgress(resumeProgressOptions, async (progress) => await this.resumeEditSession(this.environmentService.editSessionId, undefined, undefined, progress).finally(() => this.environmentService.editSessionId = undefined));
|
||||
} else if (shouldAutoResumeOnReload && this.editSessionsStorageService.isSignedIn) {
|
||||
this.logService.info('Resuming cloud changes, reason: cloud changes enabled...');
|
||||
// Attempt to resume edit session based on edit workspace identifier
|
||||
// Note: at this point if the user is not signed into edit sessions,
|
||||
// we don't want them to be prompted to sign in and should just return early
|
||||
await this.progressService.withProgress(resumingProgressOptions, async () => await this.resumeEditSession(undefined, true));
|
||||
await this.progressService.withProgress(resumeProgressOptions, async (progress) => await this.resumeEditSession(undefined, true, undefined, progress));
|
||||
} else if (shouldAutoResumeOnReload) {
|
||||
// The application has previously launched via a protocol URL Continue On flow
|
||||
const hasApplicationLaunchedFromContinueOnFlow = this.storageService.getBoolean(EditSessionsContribution.APPLICATION_LAUNCHED_VIA_CONTINUE_ON_STORAGE_KEY, StorageScope.APPLICATION, false);
|
||||
|
@ -161,7 +163,7 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
|
|||
// attempt a resume if we are in a pending state and the user just signed in
|
||||
const disposable = this.editSessionsStorageService.onDidSignIn(async () => {
|
||||
disposable.dispose();
|
||||
await this.progressService.withProgress(resumingProgressOptions, async () => await this.resumeEditSession(undefined, true));
|
||||
await this.progressService.withProgress(resumeProgressOptions, async (progress) => await this.resumeEditSession(undefined, true, undefined, progress));
|
||||
this.storageService.remove(EditSessionsContribution.APPLICATION_LAUNCHED_VIA_CONTINUE_ON_STORAGE_KEY, StorageScope.APPLICATION);
|
||||
this.environmentService.continueOn = undefined;
|
||||
});
|
||||
|
@ -175,7 +177,7 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
|
|||
this.storageService.store(EditSessionsContribution.APPLICATION_LAUNCHED_VIA_CONTINUE_ON_STORAGE_KEY, true, StorageScope.APPLICATION, StorageTarget.MACHINE);
|
||||
await this.editSessionsStorageService.initialize(true);
|
||||
if (this.editSessionsStorageService.isSignedIn) {
|
||||
await this.progressService.withProgress(resumingProgressOptions, async () => await this.resumeEditSession(undefined, true));
|
||||
await this.progressService.withProgress(resumeProgressOptions, async (progress) => await this.resumeEditSession(undefined, true, undefined, progress));
|
||||
} else {
|
||||
handlePendingEditSessions();
|
||||
}
|
||||
|
@ -375,7 +377,7 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
|
|||
}
|
||||
|
||||
async run(accessor: ServicesAccessor, editSessionId?: string): Promise<void> {
|
||||
await that.progressService.withProgress(resumingProgressOptions, async () => await that.resumeEditSession(editSessionId));
|
||||
await that.progressService.withProgress({ ...resumeProgressOptions, title: resumeProgressOptionsTitle }, async () => await that.resumeEditSession(editSessionId));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
@ -413,14 +415,17 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
|
|||
}));
|
||||
}
|
||||
|
||||
async resumeEditSession(ref?: string, silent?: boolean, force?: boolean): Promise<void> {
|
||||
async resumeEditSession(ref?: string, silent?: boolean, force?: boolean, progress?: IProgress<IProgressStep>): Promise<void> {
|
||||
// Wait for the remote environment to become available, if any
|
||||
await this.remoteAgentService.getEnvironment();
|
||||
|
||||
// Edit sessions are not currently supported in empty workspaces
|
||||
// https://github.com/microsoft/vscode/issues/159220
|
||||
if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.logService.info(ref !== undefined ? `Resuming changes from cloud with ref ${ref}...` : 'Resuming changes from cloud...');
|
||||
this.logService.info(ref !== undefined ? `Resuming changes from cloud with ref ${ref}...` : 'Checking for pending cloud changes...');
|
||||
|
||||
if (silent && !(await this.editSessionsStorageService.initialize(false, true))) {
|
||||
return;
|
||||
|
@ -436,6 +441,7 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
|
|||
|
||||
performance.mark('code/willResumeEditSessionFromIdentifier');
|
||||
|
||||
progress?.report({ message: localize('checkingForWorkingChanges', 'Checking for pending cloud changes...') });
|
||||
const data = await this.editSessionsStorageService.read(ref);
|
||||
if (!data) {
|
||||
if (ref === undefined && !silent) {
|
||||
|
@ -446,6 +452,8 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
|
|||
this.logService.info(ref !== undefined ? `Aborting resuming changes from cloud as no edit session content is available to be applied from ref ${ref}.` : `Aborting resuming edit session as no edit session content is available to be applied`);
|
||||
return;
|
||||
}
|
||||
|
||||
progress?.report({ message: resumeProgressOptionsTitle });
|
||||
const editSession = data.editSession;
|
||||
ref = data.ref;
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ import { IEditorService, ISaveAllEditorsOptions } from 'vs/workbench/services/ed
|
|||
import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
|
||||
|
||||
const folderName = 'test-folder';
|
||||
const folderUri = URI.file(`/${folderName}`);
|
||||
|
@ -83,6 +84,11 @@ suite('Edit session sync', () => {
|
|||
return { choice: 1 };
|
||||
}
|
||||
});
|
||||
instantiationService.stub(IRemoteAgentService, new class extends mock<IRemoteAgentService>() {
|
||||
override async getEnvironment() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
instantiationService.stub(IConfigurationService, new TestConfigurationService({ workbench: { experimental: { editSessions: { enabled: true } } } }));
|
||||
instantiationService.stub(IWorkspaceContextService, new class extends mock<IWorkspaceContextService>() {
|
||||
override getWorkspace() {
|
||||
|
|
Loading…
Reference in a new issue