Skip to content

Commit 573fb0a

Browse files
authored
theme: add notification for auto-updated default themes (#306340)
Co-authored-by: mrleemurray <mrleemurray@users.noreply.github.com>
1 parent 9d3144b commit 573fb0a

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

src/vs/workbench/services/themes/browser/workbenchThemeService.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ export class WorkbenchThemeService extends Disposable implements IWorkbenchTheme
249249
await this.migrateAutoDetectColorScheme();
250250
const result = await Promise.all([initializeColorTheme(), initializeFileIconTheme(), initializeProductIconTheme()]);
251251
this.showNewDefaultThemeNotification();
252+
this.showThemeAutoUpdatedNotification();
252253
return result;
253254
}
254255

@@ -276,6 +277,56 @@ export class WorkbenchThemeService extends Disposable implements IWorkbenchTheme
276277
}));
277278
}
278279

280+
private static readonly THEME_AUTO_UPDATED_NOTIFICATION_KEY = 'workbench.themeAutoUpdatedNotification';
281+
282+
/**
283+
* Shows a one-time notification to existing users whose color theme changed
284+
* because the product default was updated (e.g. Dark Modern → VS Code Dark).
285+
* Offers the option to browse themes or revert to the previous default.
286+
*/
287+
private showThemeAutoUpdatedNotification(): void {
288+
if (this.storageService.getBoolean(WorkbenchThemeService.THEME_AUTO_UPDATED_NOTIFICATION_KEY, StorageScope.APPLICATION)) {
289+
return; // already shown
290+
}
291+
if (this.storageService.isNew(StorageScope.APPLICATION)) {
292+
return; // new user, no migration happened
293+
}
294+
295+
// Target existing users whose theme changed because the default changed.
296+
// These users have no explicit user-scoped theme value — they inherited the default.
297+
const newDefaultThemes = new Set([ThemeSettingDefaults.COLOR_THEME_DARK, ThemeSettingDefaults.COLOR_THEME_LIGHT]);
298+
if (!newDefaultThemes.has(this.currentColorTheme.settingsId)) {
299+
return; // not using a new default theme
300+
}
301+
if (!this.settings.isDefaultColorTheme()) {
302+
return; // user explicitly chose this theme
303+
}
304+
305+
const previousSettingsId = this.currentColorTheme.type === ColorScheme.LIGHT ? 'Light Modern' : 'Dark Modern';
306+
307+
const handle = this.notificationService.prompt(
308+
Severity.Info,
309+
nls.localize({ key: 'newDefaultThemeAutoUpdated', comment: ['{0} is the name of the current color theme, e.g. "VS Code Dark"'] }, "VS Code has a new look! You can keep {0}, switch to another theme, or go back to your previous one.", this.currentColorTheme.label),
310+
[{
311+
label: nls.localize('browseThemes', "Browse Themes"),
312+
run: () => this.commandService.executeCommand('workbench.action.selectTheme')
313+
}, {
314+
label: nls.localize('revertTheme', "Revert"),
315+
run: () => {
316+
const previousTheme = this.colorThemeRegistry.findThemeBySettingsId(previousSettingsId);
317+
if (previousTheme) {
318+
this.setColorTheme(previousTheme.id, 'auto');
319+
}
320+
}
321+
}]
322+
);
323+
this._register(Event.once(handle.onDidClose)(() => {
324+
this.storageService.store(WorkbenchThemeService.THEME_AUTO_UPDATED_NOTIFICATION_KEY, true, StorageScope.APPLICATION, StorageTarget.USER);
325+
// Also suppress the "try new themes" notification — this user is already aware of the new themes.
326+
this.storageService.store(WorkbenchThemeService.NEW_THEME_NOTIFICATION_KEY, true, StorageScope.APPLICATION, StorageTarget.USER);
327+
}));
328+
}
329+
279330
/**
280331
* Migrates legacy theme setting values to their current equivalents,
281332
* writing back the migrated value so settings sync distributes the correct ID.

0 commit comments

Comments
 (0)