[PR #2515] Add Cascading User + Default Settings #24977

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

Original Pull Request: https://github.com/microsoft/terminal/pull/2515

State: closed
Merged: Yes


Summary of the Pull Request

This PR represents the start of the work on Cascading User + default settings, #754.

Cascading settings will be done in two parts:

  • Layered Default+User settings (this PR)
  • Dynamic Profile Generation (#2603).

Until both are done, _neither are going in. The dynamic profiles PR will target this PR when it's ready, but will go in as a separate commit into master.

This PR covers adding one primary feature: the settings are now in two separate files:

  • a static defaults.json that ships with the package (the "default settings")
  • a profiles.json with the user's customizations (the "user settings)

User settings are layered upon the settings in the defaults settings.

References

Other things that might be related here:

  • #1378 - This seems like it's definitely fixed. The default keybindings are much cleaner, and without the save-on-load behavior, the user's keybindings will be left in a good state
  • #1398 - This might have honestly been solved by #2475

PR Checklist

Detailed Description of the Pull Request / Additional comments

  1. We start by taking all of the FromJson functions in Profile, ColorScheme, Globals, etc, and converting them to LayerJson methods. These are effectively the same, with the change that instead of building a new object, they are simply layering the values on top of this object.
  2. Next, we add tests for layering properties like that.
  3. Now, we add a defaults.json to the package. This is the file the users can refer to as our default settings.
  4. We then take that defaults.json and stamp it into an auto generated .h file, so we can use it's data without having to worry about reading it from disk.
  5. We then change the LoadAll function in CascadiaSettings. Now, the function does two loads - one from the defaults, and then a second load from the profiles.json file, layering the settings from each source upon the previous values.
  6. If the profiles.json file doesn't exist, we'll create it from a hardcoded userDefaults.json, which is stamped in similar to how defaults.json is.
  7. We also add support for unbinding keybindings that might exist in the defaults.json, but the user doesn't want to be bound to anything.
  8. We add support for hiding a profile, which is useful if a user doesn't want one of the default profiles to appear in the list of profiles.

TODO:

  • Still need to make Alt+Click work on the settings button
  • Need to write some user documentation on how the new settings model works
  • Fix the pair of tests I broke (re: Duplicate profiles)
**Original Pull Request:** https://github.com/microsoft/terminal/pull/2515 **State:** closed **Merged:** Yes --- <!-- 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 PR represents the start of the work on Cascading User + default settings, #754. Cascading settings will be done in two parts: * [ ] Layered Default+User settings (this PR) * [ ] Dynamic Profile Generation (#2603). Until _both_ are done, _neither are going in. The dynamic profiles PR will target this PR when it's ready, but will go in as a separate commit into master. This PR covers adding one primary feature: the settings are now in two separate files: * a static `defaults.json` that ships with the package (the "default settings") * a `profiles.json` with the user's customizations (the "user settings) User settings are _layered_ upon the settings in the defaults settings. <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References Other things that might be related here: * #1378 - This seems like it's definitely fixed. The default keybindings are _much_ cleaner, and without the save-on-load behavior, the user's keybindings will be left in a good state * #1398 - This might have honestly been solved by #2475 <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #754 * [x] Closes #1378 * [x] Closes #2566 * [x] I work here * [x] Tests added/passed * [x] Requires documentation to be updated - it **ABSOLUTELY DOES** <!-- 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 1. We start by taking all of the `FromJson` functions in Profile, ColorScheme, Globals, etc, and converting them to `LayerJson` methods. These are effectively the same, with the change that instead of building a new object, they are simply layering the values on top of `this` object. 2. Next, we add tests for layering properties like that. 3. Now, we add a `defaults.json` to the package. This is the file the users can refer to as our default settings. 4. We then take that `defaults.json` and stamp it into an auto generated `.h` file, so we can use it's data without having to worry about reading it from disk. 5. We then change the `LoadAll` function in `CascadiaSettings`. Now, the function does two loads - one from the defaults, and then a second load from the `profiles.json` file, layering the settings from each source upon the previous values. 6. If the `profiles.json` file doesn't exist, we'll create it from a hardcoded `userDefaults.json`, which is stamped in similar to how `defaults.json` is. 7. We also add support for _unbinding_ keybindings that might exist in the `defaults.json`, but the user doesn't want to be bound to anything. 8. We add support for _hiding_ a profile, which is useful if a user doesn't want one of the default profiles to appear in the list of profiles. ## TODO: * [x] Still need to make Alt+Click work on the settings button * [x] Need to write some user documentation on how the new settings model works * [x] Fix the pair of tests I broke (re: Duplicate profiles)
claunia added the pull-request label 2026-01-31 09:06:29 +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#24977