Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Introduce Inheritance Addendum to TSM Spec #7876

Merged
merged 8 commits into from
Oct 26, 2020

Conversation

carlos-zamora
Copy link
Member

@carlos-zamora carlos-zamora commented Oct 9, 2020

This introduces an addendum to the Terminal Settings Model spec that
covers inheritance and fallback. Basically, settings objects will now
have a reference to a parent object. If the settings object does not
have a setting defined, it will ask its parent to resolve the value. A
parent is set using the Clone() function. Copy() is used to copy the
value and structure of the settings model, whereas Clone() is used to
copy a reference to the settings model and build an inheritance tree.

References

#6904 - Terminal Settings Model Spec
#1564 - Settings UI

@carlos-zamora carlos-zamora force-pushed the dev/cazamor/spec/tsm-inheritance branch from 6d30d5f to 06d2d38 Compare October 9, 2020 23:26
@carlos-zamora carlos-zamora added Area-Settings Issues related to settings and customizability, for console or terminal Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. labels Oct 9, 2020
@carlos-zamora
Copy link
Member Author

Idea from Dustin (soon to be added):

Introduce a function similar to LayerJson(Json::Value) that layers a resolved settings object onto another one. This way, when we have profile.defaults resolved to a Profile object, we can just layer that onto other Profile objects easily, rather than re-parsing the profile.defaults json blob.

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

I'm very enamoured with this spec. I love it.

It might be worth calling out that this moves cascading into the object model instead of keeping it as a json-only concept.

I'd also suggest calling out adding an API to CascadiaSettings that gets a reference to the Default profile (profiles.defaults). That'll enable #7414's implementation to spawn incoming commandline app tabs w/ the default profile, for example.

It's clever, putting this in the object model, because any update to a lower layer object will automatically be reflected in objects on top of it, unless they're overriding it already.

Love love love the use of til::coalesce here (thanks @zadjii-msft for splitting it up and putting it in til!)

@DHowett
Copy link
Member

DHowett commented Oct 11, 2020

Incidentally, this will be a path towards fixing #5276 (because clone/inherit/apply is the same as #5276 (comment))

@DHowett
Copy link
Member

DHowett commented Oct 12, 2020

Naming: Clone and Copy are the same thing... so maybe this one needs to be something specific like static Profile Profile::CreateInheritedProfile or static Profile Profile::Inherit. Naming is the hardest part.

@zadjii-msft zadjii-msft self-assigned this Oct 12, 2020
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

These are notes from the meeting we just had. Dunno how many you wrote down, but wanted to make sure they were captured

doc/specs/#885 - Terminal Settings Model.md Outdated Show resolved Hide resolved
doc/specs/#885 - Terminal Settings Model.md Outdated Show resolved Hide resolved
doc/specs/#885 - Terminal Settings Model.md Outdated Show resolved Hide resolved
doc/specs/#885 - Terminal Settings Model.md Outdated Show resolved Hide resolved
doc/specs/#885 - Terminal Settings Model.md Outdated Show resolved Hide resolved
doc/specs/#885 - Terminal Settings Model.md Outdated Show resolved Hide resolved
doc/specs/#885 - Terminal Settings Model.md Outdated Show resolved Hide resolved
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

found a fairly large issue w/ deep copy.

@ghost ghost added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Oct 16, 2020
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

still blocking - cz may be underestimating how important copy treating parent correctly is. chatted o*line.

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Oct 16, 2020
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Oct 20, 2020
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

Looks great!

@DHowett
Copy link
Member

DHowett commented Oct 20, 2020

you may need to add the vsdx file to the spellcheck excluder

Copy link
Member

@miniksa miniksa left a comment

Choose a reason for hiding this comment

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

I'm good with this. Looks like what we discussed at the meeting. My eyes glazed at "directed acyclic graph" captain math, but I trust you there.

@microsoft-github-updates microsoft-github-updates bot changed the base branch from master to main October 22, 2020 00:27
@carlos-zamora carlos-zamora added the AutoMerge Marked for automatic merge by the bot when requirements are met label Oct 22, 2020
@ghost
Copy link

ghost commented Oct 22, 2020

Hello @carlos-zamora!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@DHowett DHowett changed the title Introduce Inheritance Addendum to TSM Spec doc: Introduce Inheritance Addendum to TSM Spec Oct 26, 2020
@DHowett DHowett merged commit 8700499 into main Oct 26, 2020
@DHowett DHowett deleted the dev/cazamor/spec/tsm-inheritance branch October 26, 2020 23:22
ghost pushed a commit that referenced this pull request Oct 27, 2020
## Summary of the Pull Request
Introduces `IInheritable` as an interface that helps move cascading settings into the Terminal Settings Model. `GlobalAppSettings` and `Profile` both are now `IInheritable`. `CascadiaSettings` was updated to `CreateChild()` for globals and each profile when we are loading the JSON data.

IInheritable does most of the heavy lifting. It introduces a two new macros and the interface. The macros help implement the fallback functionality for nullable and non-nullable settings.

## References
#7876 - Spec Addendum
#6904 - TSM Spec
#1564 - Settings UI

#7876 - `Copy()` needs to be updated to include _parent
ghost pushed a commit that referenced this pull request Nov 17, 2020
##  Summary of the Pull Request
This adds `ToJson` functions to `Profile`, `GlobalAppSettings`, and `ColorScheme`. They are used in `CascadiaSettings` to completely serialize an instance of the settings model. Thanks to #7923, all of the settings are `std::optional`, and `JsonUtils` only writes out values that are actually populated.

`CascadiaSettings::WriteSettingsToDisk` serializes the current settings and writes them to the settings.json. A backup file is created with your old contents.

#### Limitations:
- all of the color schemes are serialized regardless of them coming from defaults.json or settings.json
- keybindings/actions are copied/pasted

## References
#1564 - Settings UI
TSM Specs (#6904 and #7876)

## PR Checklist
* [x] Tests added/passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants