-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Allow generated profiles to be deleted #11007
Conversation
dd56496
to
775d00a
Compare
775d00a
to
8cc552c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do this. This feels right.
Known caveat, which we will want to have an answer for in the future: You can create a new profile based on a deleted generated profile, but it is a full deep copy. There's no way to get the "stub" back (the one that auto-updates when we change the generators(!)) yet. We can work on that, and I suspect that that's going to be a pretty narrow case. I'm only thinking about it from a settings model consistency standpoint. 😄
@@ -46,6 +46,8 @@ namespace Microsoft.Terminal.Settings.Model | |||
void CreateUnfocusedAppearance(); | |||
void DeleteUnfocusedAppearance(); | |||
|
|||
// True if the user explicitly removed this Profile from settings.json. | |||
Boolean Deleted; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can probably make this getter-only since CascadiaSettings(Serialization) uses the members directly ... right? Or do we want to expose setting this to the public API?
we used to!
If you don't mind, I would prefer a bit more of the explanation of the how in the PR body when it merges to become the commit. The reason we ended up doing it this way instead of another way/other things we considered... just so that when somebody runs a |
There's #9997, which has a collection of related thoughts, but I'm not sure it's comprehensive. |
Should we track this in a separate issue and throw it in the backlog as a CodeHealth task? It'd be nice if we could take steps to get to that imo. (note, haven't read the PR yet, just speculation) |
It might be preferable from a "cleanliness" standpoint, but it can be considered valuable to have a list of profiles the user has explicitly suppressed so we can surface it on an Extensions page. Also, Leonard's going to rewrite settings anyway, workitem or not. |
winrt::hstring newName{}; | ||
for (uint32_t candidateIndex = 0; candidateIndex < _allProfiles.Size() + 1; candidateIndex++) | ||
std::wstring newName; | ||
for (uint32_t candidateIndex = 0, count = _allProfiles.Size() + 1; candidateIndex < count; candidateIndex++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can/should you const uint32_t
the count
initialization?
Also... multiple initializations in for loops always confuse me. But I'm not willing to block over it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately you cannot have multiple different types in for loops in C++.
You can only write something like for (auto [a, b, ...] = std::tuple{ A, B, ... }; ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sad. Whatever. I'll survive.
</Flyout> | ||
</Button.Flyout> | ||
</Button> | ||
<TextBlock x:Name="DeleteButtonDisclaimer" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can really get rid of this disclaimer? I was under the impression that deleting a inbox profile from your settings.json
would still have it be present in the list of profiles, since those are in defaults.json
(they're not from a dynamic source).
Or do we log the default profile guids in state.json
somewhere? (I may have missed this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even default profiles can be removed now. If a profile isn't present in the user's settings.json, it's origin isn't OriginTag::User
. In such cases the profile will now always be marked as "hidden" (and "deleted") unless it's the first time we're encountering it.
This works even for inbox profiles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh and for your last question specifically: Yeah! We're logging all GUIDs to state.json.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yea okay, I see it now with the else if (profile.Origin() != OriginTag::User)
okay that makes sense!
Hello @lhecker! Because this pull request has the 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 (
|
Re-enables the delete button for generated profiles in the settings UI. Additionally fixes "Startup Profiles" to only list active profiles. Profiles are considered deleted if they're absent from settings.json, but their GUID has been encountered before. Or in other words, from a user's perspective: Generated profiles are added to the settings.json automatically only once. Thus if the user chooses to delete the profile (e.g. using the delete button) they aren't re-added automatically and thus appear to have been deleted. Meanwhile those generated profiles are actually only marked as "hidden" as well as "deleted", but still exist in internal profile lists. The "hidden" attribute hides them from all existing menus. The "deleted" one hides them from the settings UI and prevents them from being written to disk. It would've been preferrable of course to just not generate and add deleted profile to internal profile lists in the first place. But this would've required far more wide-reaching changes. The settings UI for instance requires a list of _all_ profiles in order to allow a user to re-create previously deleted profiles. Such an approach was attempted but discarded because of it's current complexity overhead. * Part of #9997 * A sequel to 5d36e5d * [x] Closes #10960 * [x] I work here * [x] Tests added/passed * "Startup Profiles" doesn't list deleted profiles ✔️ * Manually removing an item from settings.json removes the profile ✔️ * Removing cmd.exe and saving doesn't create empty objects (#10960) ✔️ * "Add a new profile" lists deleted profiles ✔️ * "Duplicate" recreates previously deleted profiles ✔️ * Profiles are always created with GUIDs ✔️
🎉 Handy links: |
Re-enables the delete button for generated profiles in the settings UI.
Additionally fixes "Startup Profiles" to only list active profiles.
Profiles are considered deleted if they're absent from settings.json, but their
GUID has been encountered before. Or in other words, from a user's perspective:
Generated profiles are added to the settings.json automatically only once.
Thus if the user chooses to delete the profile (e.g. using the delete button)
they aren't re-added automatically and thus appear to have been deleted.
Meanwhile those generated profiles are actually only marked as "hidden"
as well as "deleted", but still exist in internal profile lists.
The "hidden" attribute hides them from all existing menus. The "deleted" one
hides them from the settings UI and prevents them from being written to disk.
It would've been preferrable of course to just not generate and
add deleted profile to internal profile lists in the first place.
But this would've required far more wide-reaching changes.
The settings UI for instance requires a list of all profiles in order to
allow a user to re-create previously deleted profiles. Such an approach was
attempted but discarded because of it's current complexity overhead.
References
PR Checklist
Validation Steps Performed