[PR #2091] Handle connection's state #24813

Open
opened 2026-01-31 09:05:29 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/2091

State: closed
Merged: No


Summary of the Pull Request

Adds ability to check if ITerminalConnection succeeded and indicate that to user.. Terminal now shows a message when commandline process cannot be started, or when it ends (make sure to set closeOnExit: false to see that). Other connections (like Azure form #1808) can add it's own specific behaviour.

I'm making it draft, since I don't feel all that confident about this, as well as to add more, based on feedback. I would like to:

  • Make extensive connection state infrastructure/handling
  • Have more/nicer visual appearance.
    • Tab's color should be gray if tab exit's gracefully and red if abnormally.
    • Support tab's templated names, when that's a thing
  • Have nicer messages as suggested here
  • Have proper synchronization (not only in this PR's stuff)

TL;DR
image
image

References

#2039 - This PR will provide a mean to detect graceful disconnection

PR Checklist

Detailed Description of the Pull Request / Additional comments

  • Added functions to ITerminalConnection that allow to get appropriate message and tab title when connection failed or is closed. In this case the message is then displayed by terminal.
  • Since now the process is created by conhost, I added a small, short-living named pipe to ConhostConnection, through which conhost sends the creation error code (even with no error) and process handle (if created). With ConptyConnection this will be much simpler.

Validation Steps Performed

  • Launch process and exit it, e.g. powershell and type exit 123
  • In profile set commandline to something that cannot be started, like __powershell.exe
**Original Pull Request:** https://github.com/microsoft/terminal/pull/2091 **State:** closed **Merged:** No --- <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Adds ability to check if `ITerminalConnection` succeeded and indicate that to user.. Terminal now shows a message when commandline process cannot be started, or when it ends (make sure to set `closeOnExit: false` to see that). Other connections (like Azure form #1808) can add it's own specific behaviour. I'm making it draft, since I don't feel all that confident about this, as well as to add more, based on feedback. I would like to: - Make extensive connection state infrastructure/handling - Have more/nicer visual appearance. - Tab's color should be gray if tab exit's gracefully and red if abnormally. - Support tab's templated names, when that's a thing - Have nicer messages as suggested [here](https://github.com/microsoft/terminal/issues/982#issuecomment-495727765) - Have proper synchronization (not only in this PR's stuff) TL;DR ![image](https://user-images.githubusercontent.com/38111589/61879012-6f0dba00-aef2-11e9-87b9-96cbf975fe28.png) ![image](https://user-images.githubusercontent.com/38111589/61879064-8cdb1f00-aef2-11e9-9f6d-34e05aabef2c.png) <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References #2039 - This PR will provide a mean to detect graceful disconnection <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [X] Closes #982 * [X] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [ ] Requires documentation to be updated * [X] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments - Added functions to `ITerminalConnection` that allow to get appropriate message and tab title when connection failed or is closed. In this case the message is then displayed by terminal. - Since now the process is created by conhost, I added a small, short-living named pipe to `ConhostConnection`, through which conhost sends the creation error code (even with no error) and process handle (if created). With `ConptyConnection` this will be much simpler. <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed - Launch process and exit it, e.g. powershell and type `exit 123` - In profile set `commandline` to something that cannot be started, like `__powershell.exe`
claunia added the pull-request label 2026-01-31 09:05:29 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#24813