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

Create a new page for "Add new profile" in the SUI #9352

Merged
36 commits merged into from
May 5, 2021

Conversation

PankajBhojwani
Copy link
Contributor

@PankajBhojwani PankajBhojwani commented Mar 3, 2021

  • Whenever we add a new profile setting from now on we have to update
    Profile::CopySettings and CascadiaSettings::DuplicateProfile 👎

Notes from bug bash (checked bugs have been resolved):

  • The duplicate list can be very long if you have profiles
  • DH: "Create new" seems too vague. "New empty profile" or something
    seems a little clearer to me.
  • There is no deduplication counter for name
  • Crash when your settings file is corrupt and we had to fall back
    to the defaults and you duplicate a profile
  • Crash due to Crash in main when writing settings to disk twice #10003

PR Checklist

@ghost ghost added Area-Settings UI Anything specific to the SUI Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal. labels Mar 3, 2021
@DHowett
Copy link
Member

DHowett commented Mar 3, 2021

screen-shoot it!

@PankajBhojwani PankajBhojwani marked this pull request as ready for review March 6, 2021 00:59
@zadjii-msft zadjii-msft self-assigned this Mar 8, 2021
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.

I have a lot of comments, and they're all nits, really. Only requesting changes so I can come back and check it when you've addressed my stuff. You've done a fantastic job here. Thank you so much 😊!

Definitely want @cinnamon-msft to take a look at the design (after the minor XAML changes I've suggested). It feels great!

I was originally thinking that selecting a profile to duplicate would be in a combo box, but since the page is fairly empty right now, I think this makes more sense (and changing it to a combo box is like no work, really).

src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/AddProfile.idl Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/AddProfile.h Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/AddProfile.h Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/AddProfile.h Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp Outdated Show resolved Hide resolved
@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Mar 10, 2021
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Mar 10, 2021
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.

Awesome job! Thanks!

src/cascadia/TerminalSettingsEditor/AddProfile.h Outdated Show resolved Hide resolved
@PankajBhojwani PankajBhojwani added the Needs-Second It's a PR that needs another sign-off label Mar 12, 2021
@ghost ghost requested review from zadjii-msft, miniksa and leonMSFT March 12, 2021 19:17
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.

I'm a little worried about some of the edge cases with duplicating profiles and the names, guids assigned 😬

src/cascadia/TerminalSettingsEditor/MainPage.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/MainPage.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/MainPage.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp Outdated Show resolved Hide resolved
// - Duplicate a new profile based off another profile's settings
// Return Value:
// - a reference to the new profile
winrt::Microsoft::Terminal::Settings::Model::Profile CascadiaSettings::DuplicateProfile(Model::Profile source)
Copy link
Member

Choose a reason for hiding this comment

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

Is there some way we could add a test for this? To maybe prevent us from forgetting this in the future?

Maybe like if we did something where we:

  • duplicate a profile ("A" -> "A Copy")
  • manually change the name of "A Copy" back to "A"
  • Call ToJson on both profiles and compare the results?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to clarify - what would be the purpose of this test? If we want to check whether duplicating is working as intended, we could just compare the profile objects themselves without calling ToJson right?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure that a Profile actually implements any sort of logical compare with other profiles - so I was thinking the ToJson would be a handy shortcut, rather writing code that actually compares the values of each and every property.

This is more of a thought experiment so you can ignore it for now

_allProfiles.Append(*duplicated);

const auto newName{ fmt::format(L"{} ({})", source.Name(), RS_(L"CopySuffix")) };
duplicated->Name(winrt::hstring(newName));
Copy link
Member

Choose a reason for hiding this comment

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

okay hear me out - what if you have two profiles already: ["A", "A Copy"]. If you duplicate "A", what happens? Two "A Copy" profiles?

Copy link
Contributor Author

@PankajBhojwani PankajBhojwani Mar 15, 2021

Choose a reason for hiding this comment

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

Only one of the Copy profiles will show up after the user hits 'save', which is the same thing that happens if a user manually creates two profiles with the same name so I feel like it should be okay?

Copy link
Member

Choose a reason for hiding this comment

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

Should we do the thing that like, explorer (et. al) do where it's like "Foo" -> "Foo Copy" -> "Foo Copy(1)" -> "Foo Copy(2)" -> etc? Like, it seems to me that the action that's being requested by the user is "make me a new profile", so we should definitely give them a fresh one.

I suppose we could address both this and "if a user manually creates two profiles with the same name (using the UI)" at the same time in a follow up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Follow up sounds good - though I would also like some discussion before that on whether this is strictly necessary!

Copy link
Member

Choose a reason for hiding this comment

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

For the record, this is prone to a similar bug as #9714. So I see it as the same level of importance/severity as that. I agree though, something we should be aware of as a follow up. Mind filing an issue and tagging it here (heck, maybe even expand #9714 to encompass this since it'll be a similar fix?)


const auto newName{ fmt::format(L"{} ({})", source.Name(), RS_(L"CopySuffix")) };
duplicated->Name(winrt::hstring(newName));

Copy link
Member

Choose a reason for hiding this comment

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

In the same vein - what do we do about the duplicated profile's guid? Do we manually assign it a fresh one?

If I manually generate the guid for a profile named "Foo Copy" (say it's {1}), and set the guid for a profile "Bar" to the guid to {1}, then duplicate "Foo", does that duplicated profile now conflict with "Bar"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do not manually assign any guid here, later on a guid is automatically generated for the duplicated profile from its name

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should, to avoid the (incredibly rare but absolutely possible) case from above? I think it'd be totally unexpected if you duplicated "Foo" and ended up in the settings for "Bar"

Copy link
Contributor Author

@PankajBhojwani PankajBhojwani Mar 22, 2021

Choose a reason for hiding this comment

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

I'm not sure I agree that this is on us to solve. If we're going as far as to consider what if the user manually inputs a very specific guid that will conflict with a guid we generate, then couldn't they achieve the same thing by simply manually assigning the same guid to two different profiles in their settings file? It feels like one of those 'do bad things get bad results' that I'm not sure we should try to work around

Copy link
Member

Choose a reason for hiding this comment

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

Meh, I'm fine with that for now. Just so long as we're aware of it 😉

src/cascadia/TerminalSettingsEditor/AddProfile.xaml Outdated Show resolved Hide resolved
@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 Mar 15, 2021
@github-actions
Copy link

Misspellings found, please review:

  • duplciate
To accept these changes, run the following commands from this repository on this branch
pushd $(git rev-parse --show-toplevel)
perl -e '
my @expect_files=qw('".github/actions/spelling/expect/alphabet.txt
.github/actions/spelling/expect/expect.txt
.github/actions/spelling/expect/web.txt"');
@ARGV=@expect_files;
my @stale=qw('"aef aspnet boostorg BSODs Cac COINIT dahall DEFAPP DEFCON fde fea fmtlib HPCON isocpp mintty msvcrtd NVDA pinam QOL remoting Unk unte vcrt what3words xamarin "');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
  if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
  next if /^(?:$re)(?:(?:\r|\n)*$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spelling/expect/7df4b3c823d1b64a60bf6089b249adb14ecfd458.txt";
use File::Path qw(make_path);
make_path ".github/actions/spelling/expect";
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"cac coinit defapp duplciate hpcon MSVCRTD Remoting unk "');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a) cmp lc($b)} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;'
popd
✏️ Contributor please read this

By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.

⚠️ The command is written for posix shells. You can copy the contents of each perl command excluding the outer ' marks and dropping any '"/"' quotation mark pairs into a file and then run perl file.pl from the root of the repository to run the code. Alternatively, you can manually insert the items...

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spelling/dictionary/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spelling/dictionary/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spelling/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spelling/patterns/.

See the README.md in each directory for more information.

🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉

🗜️ If you see a bunch of garbage and it relates to a binary-ish string, please add a file path to the .github/actions/spelling/excludes.txt file instead of just accepting the garbage.

File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

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 blocking to re-review. this is WYA too hot for 1.8 (which is already built)

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 12, 2021
@carlos-zamora
Copy link
Member

i'm blocking to re-review. this is WYA too hot for 1.8 (which is already built)

@PankajBhojwani @DHowett Now that v1.8 is out, can we get this merged for the bug bash on Friday?

@PankajBhojwani PankajBhojwani removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 19, 2021
@DHowett
Copy link
Member

DHowett commented Apr 23, 2021

notes mailed to Pankaj

@ghost ghost requested a review from lhecker April 26, 2021 02:14
@DHowett
Copy link
Member

DHowett commented May 5, 2021

moved notes-
addnewpage

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.

Pankaj- automerge this when you have fixed the name counter so that it.. doesn't say "Copy0" and looks more ergonomic (like, starting at "Copy 2" and having a space)

break;
}
// There is a theoretical unsigned integer wraparound, which is OK
newName = fmt::format(L"{} ({}{})", source.Name(), RS_(L"CopySuffix"), candidateIndex);
Copy link
Member

Choose a reason for hiding this comment

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

Won't this create Blah (Copy0)? That seems somewhat unergonomic.

You may want to use candidateIndex+2 (so that we skip "copy 1") and split the number and the copy suffix out with a space, like Blah (Copy 2)

@PankajBhojwani PankajBhojwani added the AutoMerge Marked for automatic merge by the bot when requirements are met label May 5, 2021
@ghost
Copy link

ghost commented May 5, 2021

Hello @PankajBhojwani!

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 b53bd67 into main May 5, 2021
@ghost ghost deleted the dev/pabhoj/add_profile_page branch May 5, 2021 04:15
@ghost
Copy link

ghost commented May 25, 2021

🎉Windows Terminal Preview v1.9.1445.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-Settings UI Anything specific to the SUI AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. 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 a profile" should lead to its own page
4 participants