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

Add a simple page for keybindings #9253

Merged
11 commits merged into from Feb 23, 2021
Merged

Add a simple page for keybindings #9253

11 commits merged into from Feb 23, 2021

Conversation

zadjii-msft
Copy link
Member

@zadjii-msft zadjii-msft commented Feb 23, 2021

This was the only thing blocking me from signing off on #9224 in 1.7.

! CHANGE WARNING !
If we bind to T.S.M.Commands in XAML, then the compiler gets very
angry
at us. It generates two different versions of
GetReferenceTypeMember_Icon in XamlTypeInfo.g.cpp. Presumably
because there's an Icon on a NavViewItem and an Icon on a Command. We
don't really know why. Fortunately, the fix is "rename Command::Icon" to
"Command::IconPath". It's dumb, but it works. Thanks for the help with
that one Carlos ☺️

Unblocks #9224

@zadjii-msft zadjii-msft added Product-Terminal The new Windows Terminal. Area-Settings UI Anything specific to the SUI labels Feb 23, 2021
@zadjii-msft
Copy link
Member Author

zadjii-msft commented Feb 23, 2021

@carlos-zamora
One weird thing in this PR: Whenever you save the settings file, the entire list disappears. Presumably because we create a new Actions page which makes a new vector of filtered actions, but then never get the OnNavigatedTo to populate the list? I'm investigating, but if you have any ideas like "oh yea that's totally happened to me before. You've got to...", that would be much appreciated


EDIT:
  • Oh it looks like in the OnNavigatedTo, none of the commands have keychordtext yet.
  • The OnNavigatedTo event happens in the second half of TerminalPage::_RefreshUIForSettingsReload
  • which happens in the first half of TerminalPage::SetSettings, before TPage::_UpdateCommandsForPalette
  • TerminalPage::_UpdateCommandsForPalette is the guy that goes through and fills in the KeyChordText for commands. On first load, it's already been done by the time the Actions page loads. On hot reloads - not so much.
    • it's a heavier piece of code that, but it's already on the UI thread for a hot-reload anyways so moving it shouldn't matter

EDIT 2: yep that worked

@cinnamon-msft
Copy link
Contributor

My only feedback is to change the page name to Actions and then scoot the right column closer to the left a bit. Otherwise, this is fantastic. :)

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 few design issues that I'm conflicted with because of a short release window:

  • nested commands should pop up in a hierarchical view
  • if a command doesn't have a name, it won't appear in the list, right?

We've basically created a command palette copy in the settings UI. But in that case, what value does it add? Why doesn't the user just open the command palette in another tab and get nested commands for free?

I'm not approving because I'm genuinely conflicted by the value this adds. But I'm not going to block it because it seems to be what we want. I'll circle back to how I feel about this in the afternoon.

Comment on lines 198 to 200
<data name="Globals_KeybindingsLink.Content" xml:space="preserve">
<value>Open JSON settings</value>
</data>
Copy link
Member

Choose a reason for hiding this comment

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

nit: maybe to try and reduce loc burden, could we just reuse the Nav_OpenJson/Content?

Comment on lines 353 to 355
<data name="Nav_Actions.Content" xml:space="preserve">
<value>Keybindings</value>
</data>
Copy link
Member

Choose a reason for hiding this comment

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

According to this design doc, I think it's supposed to be named "Keyboard". But I feel like we changed it at some point. @cinnamon-msft can you confirm what the name should be?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm torn on this now. I like Keyboard because it clearly shows the user where to find key bindings. However, our JSON uses Actions, so if someone wanted to edit their keys, would they know they'd have to edit the Actions array?

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay I'm going with Actions for now. The later in the day we get, the harder it will be to change again

Comment on lines +163 to +164
<TextBlock x:Uid="Globals_KeybindingsDisclaimer"
Style="{StaticResource DisclaimerStyle}"/>
Copy link
Member

Choose a reason for hiding this comment

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

(not @zadjii-msft's fault, but still relevant) This text block is not read by a screen reader (same with the disclaimer in base layer). I'll file a separate issue to track this one.

Copy link
Member

Choose a reason for hiding this comment

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

This is going to be important for us to fix before any settings UI goes stable. Why are they not read?

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to:
"Disclaimer" text boxes are not read in narrator #9255


<ListView HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
SelectionMode="Single"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
SelectionMode="Single"
SelectionMode="None"
IsItemClickEnabled="False"

Should we make it so that you can't interact with this? There's no reason for a user to select entries.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, why not?

SelectionMode="Single"
CanReorderItems="False"
AllowDrop="False"
ItemsSource="{x:Bind FilteredActions}"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ItemsSource="{x:Bind FilteredActions}"
ItemsSource="{x:Bind FilteredActions, Mode="OneWay"}"

We should bind this OneWay. This may have caused some mayhem for you in trying to figure out why it didn't repopulate?

{
runtimeclass ActionsPageNavigationState
{
Microsoft.Terminal.Settings.Model.CascadiaSettings Settings;
Copy link
Member

Choose a reason for hiding this comment

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

It seems like we only need GlobalAppSettings to get access to the list of commands. We should pass that in instead of the whole settings object.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, this was me being quick and dirty

Copy link
Member

Choose a reason for hiding this comment

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

I suspect we will eventually need the whole thing. Just like Profiles needs Color Schemes.

what we really need is a viewmodel.

src/cascadia/TerminalSettingsEditor/Actions.h Show resolved Hide resolved
looks quite redundant -->
<ContentPresenter x:Uid="Globals_Keybindings" Margin="0">

<ListView HorizontalAlignment="Stretch"
Copy link
Member

Choose a reason for hiding this comment

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

I feel like we should have a header for each column here. But that's so much extra work for a small release window. Plus additional loc burden.

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.

Ok. Sat down and thought about this more. I think what we have here is great for WT Preview. I'd like for it to get some kind of polish over the next month before it hits stable. But we'll just need some community feedback.

We'll also just have to have a conversation on how we want to transition from this read-only view to the actual one. I'm starting to think of some ideas for what that'll look like, but we really need @cinnamon-msft to fully design that out.

@zadjii-msft
Copy link
Member Author

  • nested commands should pop up in a hierarchical view

The point of this page is to quickly display a list of all the keybindings. Not of all the actions/commands. Not to expose the structure of the command palette. I'm not aware of anyone who's got a key bound to a nested command - there certainly aren't any bound by default. I'm willing to accept the bug for now that "nested actions with a key bound don't show up in the list of keybindings". (probably easy to fix now tbh...)

  • if a command doesn't have a name, it won't appear in the list, right?

Correct. There's few and far between commands that don't have a generated name - usually that's due to parameters not being valid. I'll be shocked if someone reports "but muh command with a null name isn't displayed there". This is an artifact of me using the Commands map to get these keybindings, not the KeyMap. The Commands can't have null names, because the Name is the key. The KeyMap can have null names, but it's also not iterable?

We've basically created a command palette copy in the settings UI. But in that case, what value does it add? Why doesn't the user just open the command palette in another tab and get nested commands for free?

Because already, nobody knows about the command palette. That's pretty consistently something I mention and people go "oh, that's neat, didn't know about that". The point here is 99% to just say "these are the current keybindings, you can edit them in the file", rather than have people ask how they change their keybindings with the settings UI. The target audience here is the user who knows 10% about the terminal, who might not even know the Terminal has remappable keys. I'm guessing people that already know to go to the file to change their keybindings are in the 50% range. People who are actively using actions to add commands and nested commands are probably the top 90%. The 50% and 90% users don't really need this page at all.

I'm 100% okay throwing this out when the real UI lands. This is supposed to be throw-away code.

@DHowett
Copy link
Member

DHowett commented Feb 23, 2021

Before adding icons consider that 0 of our built in actions have icons. I’d rather pass on additional complexity

@@ -16,7 +16,7 @@ namespace Microsoft.Terminal.Settings.Model
ActionAndArgs Action;
String KeyChordText;

String Icon;
String IconPath;
Copy link
Member

Choose a reason for hiding this comment

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

but but but iuts' not a path
so sad about this :|

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'd really really love for this to not be totally insane.

IconSource? idk. When I get more time, I'm gonna set up a simple repro for the WinUI team to tell me exactly wtf is going on here.

src/cascadia/TerminalApp/TerminalPage.cpp Show resolved Hide resolved
{
runtimeclass ActionsPageNavigationState
{
Microsoft.Terminal.Settings.Model.CascadiaSettings Settings;
Copy link
Member

Choose a reason for hiding this comment

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

I suspect we will eventually need the whole thing. Just like Profiles needs Color Schemes.

what we really need is a viewmodel.

Comment on lines +163 to +164
<TextBlock x:Uid="Globals_KeybindingsDisclaimer"
Style="{StaticResource DisclaimerStyle}"/>
Copy link
Member

Choose a reason for hiding this comment

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

This is going to be important for us to fix before any settings UI goes stable. Why are they not read?

@zadjii-msft
Copy link
Member Author

works in HC:
image

@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Feb 23, 2021
@ghost
Copy link

ghost commented Feb 23, 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 f87596f into main Feb 23, 2021
@ghost ghost deleted the dev/migrie/actions-list branch February 23, 2021 23:37
@ghost
Copy link

ghost commented Mar 1, 2021

🎉Windows Terminal Preview v1.7.572.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 Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants