[PR #14064] [MERGED] Add support for switching the scheme based on the app's theme #29909

Open
opened 2026-01-31 09:37:33 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/14064
Author: @bennettnicholas
Created: 9/23/2022
Status: ✅ Merged
Merged: 12/6/2022
Merged by: @undefined

Base: main ← Head: ThemeControlledColorSchemeSwitch


📝 Commits (10+)

  • 3d5d88a inintial buggy fix for syncing OS themes
  • 5f54750 fixed control preview bug
  • 43cc9fa Code cleanup
  • e4c2d20 Code cleanup
  • b1c5342 updated bug, where custom themes would not update the color scheme
  • e4f3625 updated bug, where custom themes would not update the color scheme
  • c16b998 PR lhecker comments
  • 4e40eff formatting fix
  • 367d38c formatting fix
  • fdc2c80 Merge remote-tracking branch 'origin/main' into ThemeControlledColorSchemeSwitch

📊 Changes

33 files changed (+347 additions, -143 deletions)

View changed files

📝 doc/cascadia/profiles.schema.json (+31 -2)
📝 src/cascadia/LocalTests_SettingsModel/ColorSchemeTests.cpp (+88 -10)
📝 src/cascadia/LocalTests_SettingsModel/DeserializationTests.cpp (+9 -3)
📝 src/cascadia/LocalTests_SettingsModel/SerializationTests.cpp (+8 -8)
📝 src/cascadia/LocalTests_SettingsModel/TerminalSettingsTests.cpp (+9 -8)
📝 src/cascadia/LocalTests_SettingsModel/pch.h (+1 -0)
📝 src/cascadia/TerminalApp/App.cpp (+1 -1)
📝 src/cascadia/TerminalApp/AppLogic.cpp (+42 -48)
📝 src/cascadia/TerminalApp/AppLogic.h (+2 -2)
📝 src/cascadia/TerminalApp/AppLogic.idl (+1 -1)
📝 src/cascadia/TerminalSettingsEditor/Appearances.cpp (+4 -3)
📝 src/cascadia/TerminalSettingsEditor/Appearances.h (+2 -1)
📝 src/cascadia/TerminalSettingsEditor/Appearances.idl (+2 -1)
📝 src/cascadia/TerminalSettingsEditor/Appearances.xaml (+4 -3)
📝 src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.cpp (+3 -1)
📝 src/cascadia/TerminalSettingsEditor/ColorSchemesPageViewModel.cpp (+2 -1)
📝 src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp (+29 -0)
📝 src/cascadia/TerminalSettingsModel/AppearanceConfig.h (+3 -0)
📝 src/cascadia/TerminalSettingsModel/AzureCloudShellGenerator.cpp (+2 -1)
📝 src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp (+38 -32)

...and 13 more files

📄 Description

Summary of the Pull Request

This pull request solved the problem of users not being able to set color schemes specifically for dark or light mode. Now the code has been updated to accept a dark and light color scheme in the json. The old setting is still compatible. Keep in mind if you update your color scheme through the settings UI, it will set both dark and light to the color scheme selected. This is because the settings UI update for selecting both Dark and Light color schemes is not supported yet.

This also solves the problem of the UI not using the system OS theme. Now you can select system theme and your color scheme will be selected based on if the system theme is dark or light.

References

#4066

PR Checklist

Detailed Description of the Pull Request / Additional comments

-Removed ColorSchemeName from MTSMSettings.h in order to process the setting for both string and object.
-Added DarkColorSchemeName and LightColorSchemeName properties to the AppearanceConfig to replace ColorSchemeName.
-Hacked a few processes to play nice with all 3 properties listed above as in some cases around the UI, we need to still use the ColorSchemeName. Once we change the UI I believe we can go back to just Dark and LightColorSchemeName
-Added and Updated Test to align to the new code.

Acceptable Json values,

"colorScheme":
{
"dark": "Campbell",
"light": "Campbell"
}
or

"colorScheme": "Campbell"

Validation Steps Performed

Individual testing along with the test case added.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/14064 **Author:** [@bennettnicholas](https://github.com/bennettnicholas) **Created:** 9/23/2022 **Status:** ✅ Merged **Merged:** 12/6/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `ThemeControlledColorSchemeSwitch` --- ### 📝 Commits (10+) - [`3d5d88a`](https://github.com/microsoft/terminal/commit/3d5d88a41def9d7e17fabfe44b20992f1419f5c8) inintial buggy fix for syncing OS themes - [`5f54750`](https://github.com/microsoft/terminal/commit/5f547501b56d112447d87f121bb28b8f664162f1) fixed control preview bug - [`43cc9fa`](https://github.com/microsoft/terminal/commit/43cc9fadd602028f47f850de62be8bf1c48fc172) Code cleanup - [`e4c2d20`](https://github.com/microsoft/terminal/commit/e4c2d202ea29d08d6191d1d591bbc945f453a865) Code cleanup - [`b1c5342`](https://github.com/microsoft/terminal/commit/b1c53424e16f1db67d386599252d666c51af9c15) updated bug, where custom themes would not update the color scheme - [`e4f3625`](https://github.com/microsoft/terminal/commit/e4f362579e62e57beab7c75b09484da5f2b712d5) updated bug, where custom themes would not update the color scheme - [`c16b998`](https://github.com/microsoft/terminal/commit/c16b998e6f9ccbfefd7fe37ef8cd8ec3b116cf65) PR lhecker comments - [`4e40eff`](https://github.com/microsoft/terminal/commit/4e40eff737581ce170dec788c51be6b2ef49396a) formatting fix - [`367d38c`](https://github.com/microsoft/terminal/commit/367d38ce145c48b8f04348f1257f3bde4f0f39b9) formatting fix - [`fdc2c80`](https://github.com/microsoft/terminal/commit/fdc2c80b87a44b916490ca5e5dc7fd2c09b1110f) Merge remote-tracking branch 'origin/main' into ThemeControlledColorSchemeSwitch ### 📊 Changes **33 files changed** (+347 additions, -143 deletions) <details> <summary>View changed files</summary> 📝 `doc/cascadia/profiles.schema.json` (+31 -2) 📝 `src/cascadia/LocalTests_SettingsModel/ColorSchemeTests.cpp` (+88 -10) 📝 `src/cascadia/LocalTests_SettingsModel/DeserializationTests.cpp` (+9 -3) 📝 `src/cascadia/LocalTests_SettingsModel/SerializationTests.cpp` (+8 -8) 📝 `src/cascadia/LocalTests_SettingsModel/TerminalSettingsTests.cpp` (+9 -8) 📝 `src/cascadia/LocalTests_SettingsModel/pch.h` (+1 -0) 📝 `src/cascadia/TerminalApp/App.cpp` (+1 -1) 📝 `src/cascadia/TerminalApp/AppLogic.cpp` (+42 -48) 📝 `src/cascadia/TerminalApp/AppLogic.h` (+2 -2) 📝 `src/cascadia/TerminalApp/AppLogic.idl` (+1 -1) 📝 `src/cascadia/TerminalSettingsEditor/Appearances.cpp` (+4 -3) 📝 `src/cascadia/TerminalSettingsEditor/Appearances.h` (+2 -1) 📝 `src/cascadia/TerminalSettingsEditor/Appearances.idl` (+2 -1) 📝 `src/cascadia/TerminalSettingsEditor/Appearances.xaml` (+4 -3) 📝 `src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.cpp` (+3 -1) 📝 `src/cascadia/TerminalSettingsEditor/ColorSchemesPageViewModel.cpp` (+2 -1) 📝 `src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp` (+29 -0) 📝 `src/cascadia/TerminalSettingsModel/AppearanceConfig.h` (+3 -0) 📝 `src/cascadia/TerminalSettingsModel/AzureCloudShellGenerator.cpp` (+2 -1) 📝 `src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp` (+38 -32) _...and 13 more files_ </details> ### 📄 Description <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request This pull request solved the problem of users not being able to set color schemes specifically for dark or light mode. Now the code has been updated to accept a dark and light color scheme in the json. The old setting is still compatible. Keep in mind if you update your color scheme through the settings UI, it will set both dark and light to the color scheme selected. This is because the settings UI update for selecting both Dark and Light color schemes is not supported yet. This also solves the problem of the UI not using the system OS theme. Now you can select system theme and your color scheme will be selected based on if the system theme is dark or light. <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References #4066 <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #4066 * [x] Closes #14050 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA. * [x] Tests added/passed I believe so, added one test to ColorSchemeTests.cpp and I believe it passed. Also had to modify TerminalSettingsTests.cpp to accept the new ApplyAppearanceSettings function template * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [x] Schema updated. * [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #4066 and also teams messages with @carlos-zamora <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments -Removed ColorSchemeName from MTSMSettings.h in order to process the setting for both string and object. -Added DarkColorSchemeName and LightColorSchemeName properties to the AppearanceConfig to replace ColorSchemeName. -Hacked a few processes to play nice with all 3 properties listed above as in some cases around the UI, we need to still use the ColorSchemeName. Once we change the UI I believe we can go back to just Dark and LightColorSchemeName -Added and Updated Test to align to the new code. Acceptable Json values, "colorScheme": { "dark": "Campbell", "light": "Campbell" } or "colorScheme": "Campbell" <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed Individual testing along with the test case added. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:37:33 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#29909