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

Reintroduce the Defaults page and the Reset buttons #10588

Merged
12 commits merged into from
Jul 9, 2021

Conversation

DHowett
Copy link
Member

@DHowett DHowett commented Jul 8, 2021

This pull request brings back the "Base Layer" page, now renamed to
"Defaults", and the "Reset to inherited value" buttons. The scope of
inheritance for which buttons will display has been widened.

The button will be visible in the following cases:

The user has set a setting for the current profile, and it overrides...

  1. ... something in profiles.defaults.
  2. ... something in a Fragment Extension profile.
  3. ... something from a Dynamic Profile Generator.
  4. ... something from the compiled-in defaults.

Compared to the original implementation of reset arrows, cases (1), (3)
and (4) are new. Rationale:

(1) The user can see a setting on the Defaults page, and they need a way
to reset back to it.

(3) Dynamic profiles are not meaningfully different from fragments, and
users may need a way to reset back to the default value generated
for WSL or PowerShell.

(4) The user can see a setting on the Defaults page, BUT they are
not the one who created it. They still need a way to get back to
it.

To support this, I've introduced another origin tag, "User", and renamed
"Custom" to "None". Due to the way origin/override detection works¹, we
cannot otherwise disambiguate between settings that came from the user
and settings that came from the compiled-in defaults.

Changes were required in TerminalSettings such that we could construct a
settings object with a profile that does not have a GUID. In making this
change, I fixed a bit of silliness where we took a profile, extracted
its guid, and used that guid to look up the same profile object. Oops.

I also fixed the PropertyChanged notifier to include the
XxxOverrideSource property.

The presence of the page and the reset arrows is restricted to
Preview- or Dev-branded builds. Stable builds will retain their current
behavior.

¹ XxxOverrideSource returns the profile above the current profile
that holds a value for setting Xxx. When the value is the
compiled-in value, XxxOverrideSource will be null. Since it's
supposed to be the profile above the current profile, it will also be
null if the profile contains a setting at this layer.
In short, null means "user specified" or "compiled in". Oops.

Fixes #10430

Validation

  • Tested Release build to make sure it's mostly arrow-free (apart from fragments)

DHowett added 7 commits June 15, 2021 15:45
Why do we pass a profile's guid into
TermSettings::CreateWithProfileByID just so it can look up the profile
object we are already holding?

Let's not do that.
This commit introduces a new origin and makes sure that we set it to
"User" when we're processing a user's profiles. It sucks.
@ghost ghost added Area-SettingsUI Anything specific to the SUI Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. labels Jul 8, 2021
Comment on lines 900 to 904
if (_userDefaultProfileSettings)
{
// If we've loaded defaults{} we're in the "user settings" phase for sure
profile->Origin(OriginTag::User);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

@carlos-zamora this is the part that I am iffy on. I don't like it, but it is the easiest way to know that we are currently processing the user profile list compartment :|

Copy link
Member Author

Choose a reason for hiding this comment

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

This crashes when profile is null -- why is profile null? i guess it's.. a first-run scenario? I'm not actually sure...

Copy link
Member Author

Choose a reason for hiding this comment

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

ah, it's a profile that my DPG no longer emits

@DHowett DHowett marked this pull request as ready for review July 8, 2021 18:20
Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for doing this!

src/features.xml Outdated Show resolved Hide resolved
<name>Feature_ShowProfileDefaultsInSettings</name>
<description>Whether to show the "base layer" ("defaults") page in the Terminal settings UI</description>
<stage>AlwaysEnabled</stage>
<!-- This feature will not ship to Stable until it is complete. -->
Copy link
Member

Choose a reason for hiding this comment

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

Project management question:
Do we (want to) have an issue tracking this? Technically it'd be #10430, but I know we hope to iterate on this before going to stable. Idk if you want to keep some kind of issue open to track "get this in a position we're ready for it to go into stable"?

Copy link
Member Author

Choose a reason for hiding this comment

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

I feel like we're not gonna forget about this one no matter how we do it

Copy link
Member Author

Choose a reason for hiding this comment

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

i added 10430 to the <id> field in the feature doc

if (name() != value) \
{ \
target.name(value); \
_NotifyChanges(L"Has" #name, L#name, L#name "OverrideSource"); \
Copy link
Member

Choose a reason for hiding this comment

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

Wait. These shouldn't be necessary right? "OverrideSource" is the deduced value from our parent. So changing any setting shouldn't affect the value we get from our parent.

Copy link
Member Author

Choose a reason for hiding this comment

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

XxxOverrideSource is our parent. It changes (goes from returning null to non-null) if the value of HasXxx changes. Technically it doesn't matter if we notify on it because the listener is also listening for HasXxx changing.

src/cascadia/TerminalSettingsEditor/SettingContainer.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/SettingContainer.cpp Outdated Show resolved Hide resolved
DHowett and others added 2 commits July 9, 2021 11:43
Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
@DHowett DHowett added the Needs-Second It's a PR that needs another sign-off label Jul 9, 2021
@ghost ghost requested review from miniksa, leonMSFT and lhecker July 9, 2021 18:49
@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jul 9, 2021
@ghost
Copy link

ghost commented Jul 9, 2021

Hello @DHowett!

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.

@ghost ghost merged commit d57fb84 into main Jul 9, 2021
@ghost ghost deleted the dev/duhowett/bring_back_my_defaults! branch July 9, 2021 22:03
@ghost
Copy link

ghost commented Jul 14, 2021

🎉Windows Terminal Preview v1.10.1933.0 has been released which incorporates this pull request.:tada:

Handy links:

DHowett added a commit that referenced this pull request Aug 23, 2021
Right now, we store GUIDs in panes and most of the functions for interacting
with profiles on the settings model take GUIDs and look up profiles.

This pull request changes how we store and look up profiles to prefer profile
objects. Panes store strong references to their originating profiles, which
simplifies settings lookup for CloseOnExit and the bell settings. In fact,
deleting a pane's profile no longer causes it to forget which CloseOnExit
setting applies to it. Duplicating a pane that is hosting a deleted profile
(#5047) now duplicates the profile, even though it is otherwise unreachable.

This makes the world more consistent and allows us to _eventually_ support panes
hosting profiles that do not have GUIDs that can be looked up in the profile
list. This is a gateway to #6776 and #10669, and consolidating the profile
lookup logic will help with #10952.

PR #10588 introduced TerminalSettings::CreateWithProfile and made
...CreateWithProfileByID a thin wrapper over top it, which looked up the profile
by GUID before proceeding. It has also been removed, as its last caller is gone.

Closes #5047
@ghost
Copy link

ghost commented Oct 20, 2021

🎉Windows Terminal v1.11.2921.0 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-SettingsUI Anything specific to the SUI 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. Needs-Second It's a PR that needs another sign-off Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Base layer back into the SUI as "Defaults"
3 participants