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

[CmdLineArgs] "--keepOpen" to keep the window/tab/pane open after the process/profile has exited. #16497

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

htcfreek
Copy link

@htcfreek htcfreek commented Dec 25, 2023

Summary of the Pull Request

Adding a parameter to wt.exe that stops WT from closing after the sub process has exited.

References and Relevant Issues

Detailed Description of the Pull Request / Additional comments

This PR add the command line argument --keepOpen (short: -o) that stops WT from closing after the sub process has exited. This is done by overriding the Profile termination behavior setting at runtime with Never.

The new parameter is implemented as new-tab parameter and supports to be written to/read from a command line arguments JSON file.

Validation Steps Performed

  • ✅ Tested that the new parameter is recognized on long and short form.
  • 🔲 Tested that the new parameter stops WT from closing regardless of the current setting choice.
  • 🔲 Tested that the new parameter not changes the setting permanently.
  • ❌ Tested that the net tests succeed. => Added, but all command line tests are failing.
  • 🔲 Tested the following parameter cases:
Command line Result Reason
wt.exe --keepOpen ping.exe learn.microsoft.com
wt.exe --keepOpen cmd.exe /c echo "test"
wt.exe -o cmd.exe /c echo "test"
wt.exe new-tab --keepOpen PowerShell -c Get-Service
wt.exe nt -p "Command Prompt" --keepOpen
wt.exe nt -p "PowerShell" --keepOpen
wt.exe nt -p "Windows PowerShell" -o
wt.exe -p "Command Prompt" ; split-pane -p "PowerShell" --keepOpen
wt.exe -p "Command Prompt" ; split-pane -p "PowerShell" -o
wt.exe --keepOpen -p "Command Prompt" ; split-pane -p "PowerShell"
wt.exe new-tab --keepOpen PowerShell --appendCommandLine -- Write-Host test
wt.exe new-tab -o PowerShell --appendCommandLine -- Write-Host test

PR Checklist

@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Task It's a feature request, but it doesn't really need a major design. Area-Commandline wt.exe's commandline arguments Product-Terminal The new Windows Terminal. labels Dec 25, 2023

This comment has been minimized.

@htcfreek htcfreek changed the title [CmdLineArgs] "--keepOpen" to keep the window/tab/pane open after the process/profile has exitted. [CmdLineArgs] "--keepOpen" to keep the window/tab/pane open after the process/profile has exited. Dec 25, 2023
@htcfreek

This comment was marked as outdated.

@htcfreek
Copy link
Author

htcfreek commented Dec 31, 2023

@zadjii-msft
Status update: I have two important problems and need your help here.

  1. wt.exe new-tab "PowerShell" --keepOpen -c Get-Service parses to the following command line: PowerShell --keepOpen -c Get-Service (Same when using the parameter --appendCommandLine -- Write-Host test.)
  2. The settings of the profile are using the default value/value form settings.json and my parameter is ignored: What I need to know is, where can I manipulate the behavior of the profile/terminal?
  3. [not important] wt.xe -? is incomplete and does not show the new parameter. (See my code comment.)

@htcfreek
Copy link
Author

htcfreek commented May 7, 2024

@zadjii-msft , @DHowett
Can you please look at this PR. I am not sure if it makes sense to keep it open as I don't know why it isn't working? Please give me some feedback.

@zadjii-msft
Copy link
Member

My apologies! I think this one slipped through the cracks while I was off being distracted writing sudo. I can try and take a spin through the review - though, I might be a little more brief than usual until after Build (May 21-23)

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.

honestly the rest of this looks like it should work

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label May 7, 2024
@zadjii-msft
Copy link
Member

wt.exe new-tab "PowerShell" --keepOpen -c Get-Service

You'll probably want wt.exe new-tab -p "PowerShell" --keepOpen --appendCommandLine -c Get-Service (note the -p, to make sure it uses the PowerShell profile).

@microsoft-github-policy-service microsoft-github-policy-service bot added the No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. label May 14, 2024
@htcfreek

This comment has been minimized.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. labels May 14, 2024
@zadjii-msft zadjii-msft removed the Needs-Attention The core contributors need to come back around and look at this ASAP. label May 14, 2024
@htcfreek
Copy link
Author

htcfreek commented Jun 24, 2024

wt.exe new-tab "PowerShell" --keepOpen -c Get-Service

You'll probably want wt.exe new-tab -p "PowerShell" --keepOpen --appendCommandLine -c Get-Service (note the -p, to make sure it uses the PowerShell profile).

The problem was a wrong parameter order. Correct order is wt.exe new-tab --keepOpen "PowerShell" -c Get-Service

This comment has been minimized.

// We try to read the setting from the command line arguments
if (const auto& settings{ _cache.TryLookup(_profile) })
{
const auto closeMode = settings.DefaultSettings().CloseOnExit();
Copy link
Author

@htcfreek htcfreek Jun 24, 2024

Choose a reason for hiding this comment

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

@zadjii-msft
I have updated the code to handle the command line setting now. But it doesn't work because closeMode is always the value from Profile settings and never the updated value after command line parsing. How can I get the updated value that I manipulate in the command line parser?

Copy link
Author

Choose a reason for hiding this comment

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

Opened issue #17473.

@htcfreek
Copy link
Author

@zadjii-msft
All command line tests failed. The tests I have updated and the tests I did not changed.
The message is

    *********** CheckTypos - Test Start ***********
Trace Message: TerminalAppLocalTests::CommandlineTest::CheckTypos
	Message: 
	Result: Blocked
	Type: TestBlocked
	Context: TAEF
	File: 
	Function: 
	Timestamp: 01.01.0001 02:35:09
	Id: 106

*********** CheckTypos - Test Blocked ***********

What is happening here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Commandline wt.exe's commandline arguments Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a parameter for --closeOnExit
2 participants