Skip to content

Refactor theme selection action and improve error handling#306691

Draft
mrleemurray wants to merge 2 commits intomainfrom
mrleemurray/expensive-amber-aardvark
Draft

Refactor theme selection action and improve error handling#306691
mrleemurray wants to merge 2 commits intomainfrom
mrleemurray/expensive-amber-aardvark

Conversation

@mrleemurray
Copy link
Copy Markdown
Contributor

Simplify the theme selection action by removing unnecessary configuration service calls and enhance error handling when setting the color theme. This improves the overall efficiency and reliability of the theme selection process.

Copilot AI review requested due to automatic review settings March 31, 2026 09:57
@mrleemurray mrleemurray self-assigned this Mar 31, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the “Try New Default Themes” action to simplify the theme-apply flow by removing direct configuration updates and relying on IWorkbenchThemeService.setColorTheme(...) with centralized error handling.

Changes:

  • Removed IConfigurationService usage from the “Try New Default Themes” command implementation.
  • Replaced an inline async IIFE + try/catch with a single setColorTheme(...).catch(onUnexpectedError) call.

Comment on lines 611 to 616
if (!theme) {
return;
}

(async () => {
try {
await themeService.setColorTheme(theme, 'auto');
await configurationService.updateValue(ThemeSettings.PREFERRED_LIGHT_THEME, ThemeSettingDefaults.COLOR_THEME_LIGHT);
await configurationService.updateValue(ThemeSettings.PREFERRED_DARK_THEME, ThemeSettingDefaults.COLOR_THEME_DARK);
} catch (error) {
if (!isCancellationError(error)) {
onUnexpectedError(error);
}
}
})();
themeService.setColorTheme(theme, 'auto').catch(onUnexpectedError);
}));
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the updates to ThemeSettings.PREFERRED_LIGHT_THEME / ThemeSettings.PREFERRED_DARK_THEME changes the behavior of “Try New Default Themes”: accepting a pick now only sets the current theme, but no longer switches both preferred light/dark themes to the new defaults. This can prevent auto-detect from using the new defaults for the other color scheme and can also leave preferences inconsistent if the user selects the opposite-scheme theme. Consider restoring those setting updates (with appropriate error handling) or otherwise ensuring both preferred theme settings are updated to ThemeSettingDefaults.COLOR_THEME_LIGHT and ThemeSettingDefaults.COLOR_THEME_DARK when this action is accepted.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants