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 ability to save input action from command line #16513

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

e82eric
Copy link
Contributor

@e82eric e82eric commented Jan 1, 2024

Hi wanted to make an attempt at 12857. This still needs work but I think the initial version is ready to be reviewed.

Summary of the Pull Request

Mostly copied from: 6f5b9fb...1cde67a

  • Save to disk
  • If command line is empty use selection
  • Show toast
  • No UI. Trying out the different options now.

References and Relevant Issues

#12857

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

PR Checklist

  • Closes #xxx
  • Tests added/passed
  • Documentation updated
    • If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated (if necessary)

@@ -857,6 +857,18 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
AddAction(*cmd);
}

void ActionMap::AddSendInputAction(winrt::hstring name, winrt::hstring input)
Copy link
Contributor Author

@e82eric e82eric Jan 1, 2024

Choose a reason for hiding this comment

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

I tried to add this in TerminalPage::_HandleSaveTask, the build errors from calling winrt::make(input) from that project defeated me.

- Save to disk
- If command line is empty use selection
- Show toast
@e82eric e82eric force-pushed the save_input_action branch 2 times, most recently from 4ac3c7a to 5d99e7b Compare January 2, 2024 06:12
@e82eric
Copy link
Contributor Author

e82eric commented Jan 2, 2024

WindowsTerminal_SaveInput

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.

Just a drive by review for now:

  • structurally, this looks like it hits in all the right places
  • I like the confirmation toast. Great idea.
  • Testing with the commandline mode of the command palette was a clever idea here, really liked that
  • I'm excited about this and definitely need to make some additional time for this review soon

IsLightDismissEnabled="True">
<mux:TeachingTip.Content>
<StackPanel Orientation="Vertical">
<TextBox x:Name="ActionSavedNameText" Text="" />
Copy link
Member

Choose a reason for hiding this comment

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

These may need to be TextBlock's, instead of TextBoxes. Blocks are just for displaying text, while the Box is supposed to be for input. (super intuitive, I know 🙃)

winrt::hstring SaveTaskArgs::GenerateName() const
{
return winrt::hstring{
fmt::format(L"Save Task commandline:{}, name: {}, keyChord {}", Commandline(), Name(), KeyChord())
Copy link
Member

Choose a reason for hiding this comment

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

nit: we may want to omit the arg from the generated name, if the value of the arg is just empty. Like, in your gif, it always shows "keychord ," even when the keys weren't provided yet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, let me know if that looks ok.

For the toast, I have it showing None when the keyChord is null, is it better to hide the TextBlocks from the toast's content?

Right now if the same name is used I think it will overwrite the existing action, does it make sense to have a --force arg, and fail if there is a existing action for the name and no force arg?

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.

More drive-by comments. We discussed possibly holding this from 1.20 (which is gonna be a smaller, more stablization-focused release), and then merge it in for 1.21.

Sorry that we've been slow here. Hopefully in a few weeks, we'll be able to better start moving code again 😄

}
else
{
args.Name(args.GenerateName());
Copy link
Member

Choose a reason for hiding this comment

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

This right here might not be right. In the case that you don't pass a --name explicitly, this ends up setting the SaveTask::Name to something like "Save task commandline: git status". Then later, we'll build the SendInput action, and set it's name to "Save task commandline: git status".

The json for this will end up like

{
    "command": 
    {
        "action": "sendInput",
        "input": "git status"
    },
    "name": "Save Task commandline: git status"
},

I'm pretty sure we'd want to just leave that .Name empty

{
std::wstring formattedString;

if (!Name().empty() && !KeyChord().empty())
Copy link
Member

Choose a reason for hiding this comment

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

You may want to copy the pattern in SplitPaneArgs::GenerateName, which uses a stringstream, and then just adds each successive parameter to the stream (if the param is provided)


if (!Name().empty() && !KeyChord().empty())
{
formattedString = fmt::format(L"Save Task commandline: {}, name: {}, keyChord {}", Commandline(), Name(), KeyChord());
Copy link
Member

Choose a reason for hiding this comment

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

"Save Task" will almost definitely need to be in the resources.resw, and loaded with RS_ (like the other actions)

IsLightDismissEnabled="True">
<mux:TeachingTip.Content>
<StackPanel Orientation="Vertical" HorizontalAlignment="Stretch">
<TextBlock x:Name="ActionSavedNameText" Text="" />
Copy link
Member

Choose a reason for hiding this comment

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

Playing with this locally, there's still like, a faint background to these text blocks. I can't quite tell why - maybe there's a weird interaction with the acrylic of the Toast. Any chance you're seeing that? Maybe it's just me 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried a few different settings and wasn't able to notice anything. I am not able to see depths at all, so I may just be missing it.

@zadjii-msft zadjii-msft added this to the Terminal 1.21 milestone Jan 19, 2024
@e82eric
Copy link
Contributor Author

e82eric commented Jan 20, 2024

More drive-by comments. We discussed possibly holding this from 1.20 (which is gonna be a smaller, more stablization-focused release), and then merge it in for 1.21.

Sorry that we've been slow here. Hopefully in a few weeks, we'll be able to better start moving code again 😄

Sounds good! No rush on my end.

@zadjii-msft
Copy link
Member

Notes for team discussion later this week:

  • Overall, I think I'm fine with the ideas in this PR. Namely:
    • the wt save subcommand to save a commandline as a sendInput action (aka, a "task")
    • the saveTask action
    • the toasts
  • There are some annoying things that I think probably need to get done before we can ship this, and I'm volunteering to finish them in post. Namely:

But, this also lines up well with other work that's in progress (#13445 (comment)), so I'd like to get this in and keep iterating.

@zadjii-msft zadjii-msft added the Needs-Discussion Something that requires a team discussion before we can proceed label Mar 18, 2024
@zadjii-msft
Copy link
Member

Discussion feedback:

  • Stick behind velocity
  • change subcommand to x-save, ala MIME types to indicate "this subcommand is experimental"

@e82eric
Copy link
Contributor Author

e82eric commented Mar 20, 2024

I think the key chord parsing got broken with the upstream merge. I think I can take a look tonight.

@e82eric
Copy link
Contributor Author

e82eric commented Mar 21, 2024

I think the key chord parsing got broken with the upstream merge. I think I can take a look tonight.

It looks like I had broken that here. Should be fixed now.

ActionSaved(realArgs.Commandline(), realArgs.Name(), L"None");

@e82eric
Copy link
Contributor Author

e82eric commented Mar 21, 2024

Notes for team discussion later this week:

  • Overall, I think I'm fine with the ideas in this PR. Namely:

    • the wt save subcommand to save a commandline as a sendInput action (aka, a "task")
    • the saveTask action
    • the toasts
  • There are some annoying things that I think probably need to get done before we can ship this, and I'm volunteering to finish them in post. Namely:

But, this also lines up well with other work that's in progress (#13445 (comment)), so I'd like to get this in and keep iterating.

Is this along the line of what you were thinking for not displaying unfilled display params? d4eaec3

Wanted to try to address this one but wasn't sure what the behavior was. Is there a way that I can reproduce it? "should default to _the current window"

@e82eric
Copy link
Contributor Author

e82eric commented Mar 21, 2024

Discussion feedback:

  • Stick behind velocity
  • change subcommand to x-save, ala MIME types to indicate "this subcommand is experimental"

for x-save. is this along the lines of what you were thinking? 50baa7b

For the first, what does velocity mean in this context?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Discussion Something that requires a team discussion before we can proceed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants