Skip to content

Commit

Permalink
Add hyperlink to edit sessions output channel (microsoft#158987)
Browse files Browse the repository at this point in the history
  • Loading branch information
joyceerhl committed Aug 23, 2022
1 parent ea09b02 commit 6e7b7a3
Showing 1 changed file with 44 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { equals } from 'vs/base/common/objects';
import { IEditSessionIdentityService } from 'vs/platform/workspace/common/editSessions';
import { ThemeIcon } from 'vs/platform/theme/common/themeService';
import { IOutputService } from 'vs/workbench/services/output/common/output';
import * as Constants from 'vs/workbench/contrib/logs/common/logConstants';

registerSingleton(IEditSessionsLogService, EditSessionsLogService);
registerSingleton(IEditSessionsStorageService, EditSessionsWorkbenchService);
Expand All @@ -68,6 +70,16 @@ const openLocalFolderCommand: IAction2Options = {
category: EDIT_SESSION_SYNC_CATEGORY,
precondition: IsWebContext
};
const showOutputChannelCommand: IAction2Options = {
id: 'workbench.experimental.editSessions.actions.showOutputChannel',
title: { value: localize('show log', 'Show Log'), original: 'Show Log' },
category: EDIT_SESSION_SYNC_CATEGORY
};
const resumingProgressOptions = {
location: ProgressLocation.Window,
type: 'syncing',
title: `[${localize('resuming edit session window', 'Resuming edit session...')}](command:${showOutputChannelCommand.id})`
};
const queryParamName = 'editSessionId';
const experimentalSettingName = 'workbench.experimental.editSessions.enabled';

Expand Down Expand Up @@ -120,31 +132,27 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
this.lifecycleService.onWillShutdown((e) => e.join(this.autoStoreEditSession(), { id: 'autoStoreEditSession', label: localize('autoStoreEditSession', 'Storing current edit session...') }));
}

private async autoResumeEditSession() {
if (this.environmentService.editSessionId !== undefined) {
// In web, resume edit session based on an edit session GUID that
// was explicitly passed into the workbench construction options
void this.progressService.withProgress({ location: ProgressLocation.Window, type: 'syncing', title: localize('resuming edit session dialog', 'Resuming your latest edit session...') }, async () => {
performance.mark('code/willResumeEditSessionFromIdentifier');
private autoResumeEditSession() {
void this.progressService.withProgress(resumingProgressOptions, async () => {
performance.mark('code/willResumeEditSessionFromIdentifier');

type ResumeEvent = {};
type ResumeClassification = {
owner: 'joyceerhl'; comment: 'Reporting when an action is resumed from an edit session identifier.';
};
this.telemetryService.publicLog2<ResumeEvent, ResumeClassification>('editSessions.continue.resume');
type ResumeEvent = {};
type ResumeClassification = {
owner: 'joyceerhl'; comment: 'Reporting when an action is resumed from an edit session identifier.';
};
this.telemetryService.publicLog2<ResumeEvent, ResumeClassification>('editSessions.continue.resume');

if (this.environmentService.editSessionId !== undefined) {
await this.resumeEditSession(this.environmentService.editSessionId).finally(() => this.environmentService.editSessionId = undefined);

performance.mark('code/didResumeEditSessionFromIdentifier');
});
} else if (this.configurationService.getValue('workbench.experimental.editSessions.autoResume') === 'onReload' && this.editSessionsStorageService.isSignedIn) {
// 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
void this.progressService.withProgress({ location: ProgressLocation.Window, type: 'syncing', title: localize('resuming edit session window', 'Resuming edit session...') }, async () => {
} else if (this.configurationService.getValue('workbench.experimental.editSessions.autoResume') === 'onReload' && this.editSessionsStorageService.isSignedIn) {
// 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.resumeEditSession(undefined, true);
});
}
}

performance.mark('code/didResumeEditSessionFromIdentifier');
});
}

private async autoStoreEditSession() {
Expand Down Expand Up @@ -187,10 +195,24 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
this.registerContinueInLocalFolderAction();

this.registerShowEditSessionViewAction();
this.registerShowEditSessionOutputChannelAction();

this.registered = true;
}

private registerShowEditSessionOutputChannelAction() {
this._register(registerAction2(class ShowEditSessionOutput extends Action2 {
constructor() {
super(showOutputChannelCommand);
}

run(accessor: ServicesAccessor, ...args: any[]) {
const outputChannel = accessor.get(IOutputService);
void outputChannel.showChannel(Constants.editSessionsLogChannelId);
}
}));
}

private registerShowEditSessionViewAction() {
const that = this;
this._register(registerAction2(class ShowEditSessionView extends Action2 {
Expand Down Expand Up @@ -262,10 +284,7 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
}

async run(accessor: ServicesAccessor, editSessionId?: string): Promise<void> {
await that.progressService.withProgress({
location: ProgressLocation.Notification,
title: localize('resuming edit session', 'Resuming edit session...')
}, async () => {
await that.progressService.withProgress(resumingProgressOptions, async () => {
type ResumeEvent = {};
type ResumeClassification = {
owner: 'joyceerhl'; comment: 'Reporting when the resume edit session action is invoked.';
Expand Down

0 comments on commit 6e7b7a3

Please sign in to comment.