Skip to content

Commit dd7b16f

Browse files
authored
Revert changes to render featured extensions when available. (microsoft#184573)
* Lower timeouts for experimentation and gallery service * Revert changes to render extensions when available
1 parent 06ae4b6 commit dd7b16f

File tree

3 files changed

+45
-95
lines changed

3 files changed

+45
-95
lines changed

src/vs/workbench/contrib/welcomeGettingStarted/browser/featuredExtensionService.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storag
1414
import { localize } from 'vs/nls';
1515
import { IWorkbenchAssignmentService } from 'vs/workbench/services/assignment/common/assignmentService';
1616
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
17+
import { raceTimeout } from 'vs/base/common/async';
1718

1819
type FeaturedExtensionTreatment = { extensions: string[]; showAsList?: string };
1920
type FeaturedExtensionStorageData = { title: string; description: string; imagePath: string; date: number };
@@ -84,15 +85,8 @@ export class FeaturedExtensionsService extends Disposable implements IFeaturedEx
8485
return;
8586
}
8687

87-
const extensions = await Promise.race([
88-
this.tasExperimentService?.getTreatment<string>('welcome.featured.item'),
89-
new Promise<string | undefined>(resolve => setTimeout(() => resolve(''), 2000))
90-
]);
91-
92-
const extensionListTitle = await Promise.race([
93-
this.tasExperimentService?.getTreatment<string>('welcome.featured.title'),
94-
new Promise<string | undefined>(resolve => setTimeout(() => resolve(''), 2000))
95-
]);
88+
const [extensions, extensionListTitle] = await Promise.all([raceTimeout(this.tasExperimentService?.getTreatment<string>('welcome.featured.item'), 2000),
89+
raceTimeout(this.tasExperimentService?.getTreatment<string>('welcome.featured.title'), 2000)]);
9690

9791
try {
9892
this.treatment = extensions ? JSON.parse(extensions) : { extensions: [] };

src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import { IFeaturedExtensionsService } from 'vs/workbench/contrib/welcomeGettingS
7373
import { IFeaturedExtension } from 'vs/base/common/product';
7474
import { IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
7575
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
76+
import { onUnexpectedError } from 'vs/base/common/errors';
7677

7778
const SLIDE_TRANSITION_TIME_MS = 250;
7879
const configurationKey = 'workbench.startupEditor';
@@ -130,9 +131,9 @@ export class GettingStartedPage extends EditorPane {
130131

131132
// Ensure that the these are initialized before use.
132133
// Currently initialized before use in buildCategoriesSlide and scrollToCategory
133-
private recentlyOpened!: IRecentlyOpened;
134+
private recentlyOpened!: Promise<IRecentlyOpened>;
134135
private gettingStartedCategories!: IResolvedWalkthrough[];
135-
private featuredExtensions!: IFeaturedExtension[];
136+
private featuredExtensions!: Promise<IFeaturedExtension[]>;
136137

137138
private currentWalkthrough: IResolvedWalkthrough | undefined;
138139

@@ -209,10 +210,16 @@ export class GettingStartedPage extends EditorPane {
209210
this.contextService = this._register(contextService.createScoped(this.container));
210211
inWelcomeContext.bindTo(this.contextService).set(true);
211212

213+
this.gettingStartedCategories = this.gettingStartedService.getWalkthroughs();
214+
this.featuredExtensions = this.featuredExtensionService.getExtensions();
215+
212216
this._register(this.dispatchListeners);
213217
this.buildSlideThrottle = new Throttler();
214218

215219
const rerender = () => {
220+
this.gettingStartedCategories = this.gettingStartedService.getWalkthroughs();
221+
this.featuredExtensions = this.featuredExtensionService.getExtensions();
222+
216223
this.buildSlideThrottle.queue(async () => await this.buildCategoriesSlide());
217224
};
218225

@@ -227,7 +234,12 @@ export class GettingStartedPage extends EditorPane {
227234

228235
this._register(this.gettingStartedService.onDidAddWalkthrough(rerender));
229236
this._register(this.gettingStartedService.onDidRemoveWalkthrough(rerender));
230-
this._register(workspacesService.onDidChangeRecentlyOpened(rerender));
237+
238+
this.recentlyOpened = this.workspacesService.getRecentlyOpened();
239+
this._register(workspacesService.onDidChangeRecentlyOpened(() => {
240+
this.recentlyOpened = workspacesService.getRecentlyOpened();
241+
rerender();
242+
}));
231243

232244
this._register(this.gettingStartedService.onDidChangeWalkthrough(category => {
233245
const ourCategory = this.gettingStartedCategories.find(c => c.id === category.id);
@@ -725,13 +737,6 @@ export class GettingStartedPage extends EditorPane {
725737

726738
private async buildCategoriesSlide() {
727739

728-
// Delay fetching welcome page content on startup until all extensions are ready.
729-
await this.extensionService.whenInstalledExtensionsRegistered();
730-
731-
this.recentlyOpened = await this.workspacesService.getRecentlyOpened();
732-
this.gettingStartedCategories = await this.gettingStartedService.getWalkthroughs();
733-
this.featuredExtensions = await this.featuredExtensionService.getExtensions();
734-
735740
this.categoriesSlideDisposables.clear();
736741
const showOnStartupCheckbox = new Toggle({
737742
icon: Codicon.check,
@@ -831,6 +836,7 @@ export class GettingStartedPage extends EditorPane {
831836
this.currentWalkthrough = this.gettingStartedCategories.find(category => category.id === this.editorInput.selectedCategory);
832837

833838
if (!this.currentWalkthrough) {
839+
this.gettingStartedCategories = this.gettingStartedService.getWalkthroughs();
834840
this.currentWalkthrough = this.gettingStartedCategories.find(category => category.id === this.editorInput.selectedCategory);
835841
}
836842

@@ -935,11 +941,19 @@ export class GettingStartedPage extends EditorPane {
935941
});
936942

937943
recentlyOpenedList.onDidChange(() => this.registerDispatchListeners());
944+
this.recentlyOpened.then(({ workspaces }) => {
945+
// Filter out the current workspace
946+
const workspacesWithID = workspaces
947+
.filter(recent => !this.workspaceContextService.isCurrentWorkspace(isRecentWorkspace(recent) ? recent.workspace : recent.folderUri))
948+
.map(recent => ({ ...recent, id: isRecentWorkspace(recent) ? recent.workspace.id : recent.folderUri.toString() }));
949+
950+
const updateEntries = () => {
951+
recentlyOpenedList.setEntries(workspacesWithID);
952+
};
938953

939-
const entries = this.recentlyOpened.workspaces.filter(recent => !this.workspaceContextService.isCurrentWorkspace(isRecentWorkspace(recent) ? recent.workspace : recent.folderUri))
940-
.map(recent => ({ ...recent, id: isRecentWorkspace(recent) ? recent.workspace.id : recent.folderUri.toString() }));
941-
942-
recentlyOpenedList.setEntries(entries);
954+
updateEntries();
955+
recentlyOpenedList.register(this.labelService.onDidChangeFormatters(() => updateEntries()));
956+
}).catch(onUnexpectedError);
943957

944958
return recentlyOpenedList;
945959
}
@@ -1103,7 +1117,9 @@ export class GettingStartedPage extends EditorPane {
11031117
contextService: this.contextService,
11041118
});
11051119

1106-
featuredExtensionsList.setEntries(this.featuredExtensions);
1120+
this.featuredExtensions?.then(extensions => {
1121+
featuredExtensionsList.setEntries(extensions);
1122+
});
11071123

11081124
this.featuredExtensionsList?.onDidChange(() => {
11091125
this.registerDispatchListeners();
@@ -1159,7 +1175,7 @@ export class GettingStartedPage extends EditorPane {
11591175
private async scrollToCategory(categoryID: string, stepId?: string) {
11601176

11611177
if (!this.gettingStartedCategories.some(c => c.id === categoryID)) {
1162-
this.gettingStartedCategories = await this.gettingStartedService.getWalkthroughs();
1178+
this.gettingStartedCategories = this.gettingStartedService.getWalkthroughs();
11631179
}
11641180

11651181
const ourCategory = this.gettingStartedCategories.find(c => c.id === categoryID);

src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.ts

Lines changed: 10 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { joinPath } from 'vs/base/common/resources';
1818
import { FileAccess } from 'vs/base/common/network';
1919
import { EXTENSION_INSTALL_SKIP_WALKTHROUGH_CONTEXT, IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
2020
import { ThemeIcon } from 'vs/base/common/themables';
21-
import { BuiltinGettingStartedCategory, BuiltinGettingStartedStep, walkthroughs } from 'vs/workbench/contrib/welcomeGettingStarted/common/gettingStartedContent';
21+
import { walkthroughs } from 'vs/workbench/contrib/welcomeGettingStarted/common/gettingStartedContent';
2222
import { IWorkbenchAssignmentService } from 'vs/workbench/services/assignment/common/assignmentService';
2323
import { IHostService } from 'vs/workbench/services/host/browser/host';
2424
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -34,8 +34,6 @@ import { checkGlobFileExists } from 'vs/workbench/services/extensions/common/wor
3434
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
3535
import { CancellationTokenSource } from 'vs/base/common/cancellation';
3636
import { DefaultIconPath } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
37-
import { IProductService } from 'vs/platform/product/common/productService';
38-
import { ILifecycleService, LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
3937

4038
export const HasMultipleNewFileEntries = new RawContextKey<boolean>('hasMultipleNewFileEntries', false);
4139

@@ -98,8 +96,8 @@ export interface IWalkthroughsService {
9896
readonly onDidChangeWalkthrough: Event<IResolvedWalkthrough>;
9997
readonly onDidProgressStep: Event<IResolvedWalkthroughStep>;
10098

101-
getWalkthroughs(): Promise<IResolvedWalkthrough[]>;
102-
getWalkthrough(id: string): Promise<IResolvedWalkthrough>;
99+
getWalkthroughs(): IResolvedWalkthrough[];
100+
getWalkthrough(id: string): IResolvedWalkthrough;
103101

104102
registerWalkthrough(descriptor: IWalkthroughLoose): void;
105103

@@ -114,12 +112,6 @@ export interface IWalkthroughsService {
114112
const DAYS = 24 * 60 * 60 * 1000;
115113
const NEW_WALKTHROUGH_TIME = 7 * DAYS;
116114

117-
type WalkthroughTreatment = {
118-
walkthroughId: string;
119-
walkthroughStepIds?: string[];
120-
stepOrder: number[];
121-
};
122-
123115
export class WalkthroughsService extends Disposable implements IWalkthroughsService {
124116
declare readonly _serviceBrand: undefined;
125117

@@ -149,7 +141,6 @@ export class WalkthroughsService extends Disposable implements IWalkthroughsServ
149141

150142
private metadata: WalkthroughMetaDataType;
151143

152-
private registeredWalkthroughs: boolean = false;
153144
constructor(
154145
@IStorageService private readonly storageService: IStorageService,
155146
@ICommandService private readonly commandService: ICommandService,
@@ -162,9 +153,7 @@ export class WalkthroughsService extends Disposable implements IWalkthroughsServ
162153
@IHostService private readonly hostService: IHostService,
163154
@IViewsService private readonly viewsService: IViewsService,
164155
@ITelemetryService private readonly telemetryService: ITelemetryService,
165-
@IWorkbenchAssignmentService private readonly tasExperimentService: IWorkbenchAssignmentService,
166-
@IProductService private readonly productService: IProductService,
167-
@ILifecycleService private readonly lifecycleService: ILifecycleService,
156+
@IWorkbenchAssignmentService private readonly tasExperimentService: IWorkbenchAssignmentService
168157
) {
169158
super();
170159

@@ -178,28 +167,13 @@ export class WalkthroughsService extends Disposable implements IWalkthroughsServ
178167
this.initCompletionEventListeners();
179168

180169
HasMultipleNewFileEntries.bindTo(this.contextService).set(false);
181-
}
170+
this.registerWalkthroughs();
182171

183-
private async registerWalkthroughs() {
184-
185-
const treatmentString = await Promise.race([
186-
this.tasExperimentService?.getTreatment<string>('welcome.walkthrough.content'),
187-
new Promise<string | undefined>(resolve => setTimeout(() => resolve(''), 2000))
188-
]);
172+
}
189173

190-
const treatment: WalkthroughTreatment = treatmentString ? JSON.parse(treatmentString) : { walkthroughId: '' };
174+
private registerWalkthroughs() {
191175

192176
walkthroughs.forEach(async (category, index) => {
193-
let shouldReorder = false;
194-
if (category.id === treatment?.walkthroughId) {
195-
category = this.updateWalkthroughContent(category, treatment);
196-
197-
shouldReorder = (treatment?.stepOrder !== undefined && category.content.steps.length === treatment.stepOrder.length);
198-
if (shouldReorder) {
199-
category.content.steps = category.content.steps.filter((_step, index) => treatment.stepOrder[index] >= 0);
200-
treatment.stepOrder = treatment.stepOrder.filter(value => value >= 0);
201-
}
202-
}
203177

204178
this._registerWalkthrough({
205179
...category,
@@ -214,7 +188,7 @@ export class WalkthroughsService extends Disposable implements IWalkthroughsServ
214188
completionEvents: step.completionEvents ?? [],
215189
description: parseDescription(step.description),
216190
category: category.id,
217-
order: shouldReorder ? (treatment?.stepOrder ? treatment.stepOrder[index] : index) : index,
191+
order: index,
218192
when: ContextKeyExpr.deserialize(step.when) ?? ContextKeyExpr.true(),
219193
media: step.media.type === 'image'
220194
? {
@@ -239,38 +213,12 @@ export class WalkthroughsService extends Disposable implements IWalkthroughsServ
239213
});
240214
});
241215

242-
await this.lifecycleService.when(LifecyclePhase.Restored);
243-
244216
walkthroughsExtensionPoint.setHandler((_, { added, removed }) => {
245217
added.map(e => this.registerExtensionWalkthroughContributions(e.description));
246218
removed.map(e => this.unregisterExtensionWalkthroughContributions(e.description));
247219
});
248220
}
249221

250-
private updateWalkthroughContent(walkthrough: BuiltinGettingStartedCategory, experimentTreatment: WalkthroughTreatment): BuiltinGettingStartedCategory {
251-
252-
if (!experimentTreatment?.walkthroughStepIds) {
253-
return walkthrough;
254-
}
255-
256-
const walkthroughMetadata = this.productService.walkthroughMetadata?.find(value => value.id === walkthrough.id);
257-
for (const step of experimentTreatment.walkthroughStepIds) {
258-
const stepMetadata = walkthroughMetadata?.steps.find(value => value.id === step);
259-
if (stepMetadata) {
260-
261-
const newStep: BuiltinGettingStartedStep = {
262-
id: step,
263-
title: stepMetadata.title,
264-
description: stepMetadata.description,
265-
when: stepMetadata.when,
266-
media: stepMetadata.media
267-
};
268-
walkthrough.content.steps.push(newStep);
269-
}
270-
}
271-
return walkthrough;
272-
}
273-
274222
private initCompletionEventListeners() {
275223
this._register(this.commandService.onDidExecuteCommand(command => this.progressByEvent(`onCommand:${command.commandId}`)));
276224

@@ -493,22 +441,14 @@ export class WalkthroughsService extends Disposable implements IWalkthroughsServ
493441
});
494442
}
495443

496-
async getWalkthrough(id: string): Promise<IResolvedWalkthrough> {
497-
if (!this.registeredWalkthroughs) {
498-
await this.registerWalkthroughs();
499-
this.registeredWalkthroughs = true;
500-
}
444+
getWalkthrough(id: string): IResolvedWalkthrough {
501445

502446
const walkthrough = this.gettingStartedContributions.get(id);
503447
if (!walkthrough) { throw Error('Trying to get unknown walkthrough: ' + id); }
504448
return this.resolveWalkthrough(walkthrough);
505449
}
506450

507-
async getWalkthroughs(): Promise<IResolvedWalkthrough[]> {
508-
if (!this.registeredWalkthroughs) {
509-
await this.registerWalkthroughs();
510-
this.registeredWalkthroughs = true;
511-
}
451+
getWalkthroughs(): IResolvedWalkthrough[] {
512452

513453
const registeredCategories = [...this.gettingStartedContributions.values()];
514454
const categoriesWithCompletion = registeredCategories

0 commit comments

Comments
 (0)