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

spec: propose an evolution of closeOnExit #2039

Merged
merged 3 commits into from
Nov 20, 2019

Conversation

DHowett-MSFT
Copy link
Contributor

@DHowett-MSFT DHowett-MSFT commented Jul 19, 2019

Summary of the Pull Request

This pull request introduces a specification for the next generation of closeOnExit.

References

#1364 #1770

PR Checklist

Detailed Description of the Pull Request / Additional comments

Look at the spec.

Validation Steps Performed

It is a spec.

@DHowett-MSFT DHowett-MSFT added Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Area-TerminalConnection Issues pertaining to the terminal<->backend connection interface Product-Terminal The new Windows Terminal. labels Jul 19, 2019
@DHowett-MSFT
Copy link
Contributor Author

TODO:

  • create an issue
  • specify a followup change to conhost code that will propagate its subprocess's exit code

@glen-84
Copy link

glen-84 commented Jul 22, 2019

Shouldn't != 0 be = 0?

You want it to close when there is a successful (0) exit code? Or am I getting mixed up?

@mcpiroman
Copy link
Contributor

I also find this confusing. For me the default should be that
success -> exit
failature -> stay opened.

But you could also support the opposite. Say someone has long running job in the background and if it fails he can immidiately see that terminal / tab closes (it's less important if it has just finished).

@DHowett
Copy link
Member

DHowett commented Jul 22, 2019

@glen-84 correct: if closeOnExit is set to graceful, the tab will automatically close only if the connected application exits "gracefully" or successfully. The idea is that an application that runs and instantly terminates--or an application that stops accepting user input because it's died--probably put something useful on the screen for troubleshooting purposes, but an application that has exited successfully does not need any troubleshooting.

If the default switched the other way (close if != 0, stay open if 0) it would be instantly frustrating, because a user would type exit in their shell of choice and we'd just sit there telling them that the shell exited. Like they requested. Back before we introduced closeOnExit, people complained so much about that! 😁

@DHowett-MSFT
Copy link
Contributor Author

@mcpiroman that is what is suggested here (default=graceful, close tab when exit code == 0)

@mcpiroman
Copy link
Contributor

but there could be another option, failature: close when exit code != 0

@glen-84
Copy link

glen-84 commented Jul 23, 2019

@DHowett Since the spec text was not updated, I'm not sure if you realized that I was pointing out an issue on line #22. It should be == 0, and not != 0. 🙂

@DHowett-MSFT
Copy link
Contributor Author

@glen-84 I definitely misread your comment 😄


1. The existing `closeOnExit` profile key will become an enumerated string key with the following values/behaviours:
* `always` - a tab or pane hosting this profile will always be closed when the launched connection terminates.
* `graceful` - a tab or pane hosting this profile will be closed **iff** the launched connection closes with an exit code == 0.
Copy link

Choose a reason for hiding this comment

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

iff?

@DHowett-MSFT
Copy link
Contributor Author

Shorthand for “if and only if”

@glen-84
Copy link

glen-84 commented Jul 24, 2019

Shorthand for “if and only if”

Oh ... I feel like I should have known that, even though it seems fairly uncommon in programming. 🙂

iff

carlos-zamora
carlos-zamora previously approved these changes Jul 25, 2019
zadjii-msft
zadjii-msft previously approved these changes Jul 25, 2019
@mu88
Copy link

mu88 commented Oct 1, 2019

Is there already an issue that will implement the specified graceful behavior? I'd love to see this feature and an issue to subscribe would be nice.

@DHowett-MSFT
Copy link
Contributor Author

I am clearing the review status of all signed-off reviewers, and adding @mcpiroman.

@mcpiroman: This spec is inspired by your work in #2091, with some minor refinements. Thank you. 😄

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.

Just throwing a few discussion points out there. Looks good :)

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 presumed that the UI considerations for this feature would be a part of this spec - like what the Terminal does in response to failed connections for graceful/never. That's what I'm really curious about here.

Carlos has some other nits I agree with, but the rest of this seems sane

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.

Yea I like the look of this

@DHowett-MSFT DHowett-MSFT changed the title Spec: propose an evolution of closeOnExit spec: propose an evolution of closeOnExit Nov 20, 2019
@DHowett-MSFT DHowett-MSFT merged commit b3ecb73 into master Nov 20, 2019
@DHowett-MSFT DHowett-MSFT deleted the spec/duhowett/closeonexit branch November 20, 2019 23:48
DHowett-MSFT pushed a commit that referenced this pull request Nov 25, 2019
This pull request implements the new
`ITerminalConnection::ConnectionState` interface (enum, event) and
connects it through TerminalControl to Pane, Tab and App as specified in
#2039. It does so to implement `closeOnExit` = `graceful` in addition to
the other two normal CoE types.

It also:

* exposes the singleton `CascadiaSettings` through a function that
  looks it up by using the current Xaml application's `AppLogic`.
  * In so doing, we've broken up the weird runaround where App tells
    TerminalSettings to CloseOnExit and then later another part of App
    _asks TerminalControl_ to tell it what TerminalSettings said App
    told it earlier. `:crazy_eyes:`
* wires up a bunch of connection state points to `AzureConnection`.
  This required moving the Azure connection's state machine to use another
  enum name (oops).
* ships a helper class for managing connection state transitions.
* contains a bunch of template magic.
* introduces `WINRT_CALLBACK`, a oneshot callback like `TYPED_EVENT`.
* replaces a bunch of disparate `_connecting` and `_closing` members
  with just one uberstate.
* updates the JSON schema and defaults to prefer closeOnExit: graceful
* updates all relevant documentation

Specified in #2039
Fixes #2563

Co-authored-by: mcpiroman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-TerminalConnection Issues pertaining to the terminal<->backend connection interface Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants