[PR #2091] [CLOSED] Handle connection's state #24808

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/2091
Author: @mcpiroman
Created: 7/25/2019
Status: Closed

Base: masterHead: 982-shell-launch-error-message


📝 Commits (10+)

  • e987abe Error message on process creation
  • b78d5d8 Undo unnecessary changes
  • d318f15 Pid in pipe name, cursor blinking, cleanup
  • e104c9d Add comments, adjust argument values
  • 92fff98 Ah format, here we go again
  • 571a04f Add strub Azure handling
  • 7d7cb6a Pass process handle, not pid. Cursor bliking
  • b2c632a format
  • ed4deac Connection as event, macros for events
  • 7f983ec Visual state handling, rework connection events

📊 Changes

15 files changed (+496 additions, -187 deletions)

View changed files

📝 src/cascadia/TerminalApp/App.cpp (+1 -1)
📝 src/cascadia/TerminalApp/Tab.cpp (+11 -1)
📝 src/cascadia/TerminalApp/Tab.h (+2 -0)
📝 src/cascadia/TerminalConnection/AzureConnection.cpp (+40 -56)
📝 src/cascadia/TerminalConnection/AzureConnection.h (+20 -8)
📝 src/cascadia/TerminalConnection/ConhostConnection.cpp (+186 -45)
📝 src/cascadia/TerminalConnection/ConhostConnection.h (+29 -8)
📝 src/cascadia/TerminalConnection/EchoConnection.cpp (+25 -21)
📝 src/cascadia/TerminalConnection/EchoConnection.h (+17 -5)
📝 src/cascadia/TerminalConnection/ITerminalConnection.idl (+24 -2)
📝 src/cascadia/TerminalControl/TermControl.cpp (+66 -27)
📝 src/cascadia/TerminalControl/TermControl.h (+3 -3)
📝 src/cascadia/TerminalControl/TermControl.idl (+1 -0)
📝 src/inc/conpty-universal.h (+15 -0)
📝 src/server/Entrypoints.cpp (+56 -10)

📄 Description

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/2091 **Author:** [@mcpiroman](https://github.com/mcpiroman) **Created:** 7/25/2019 **Status:** ❌ Closed **Base:** `master` ← **Head:** `982-shell-launch-error-message` --- ### 📝 Commits (10+) - [`e987abe`](https://github.com/microsoft/terminal/commit/e987abe7891cc6d100ae820c94be2155e21fb425) Error message on process creation - [`b78d5d8`](https://github.com/microsoft/terminal/commit/b78d5d870bcf5c952a1f0884f0dbcee61464c8ad) Undo unnecessary changes - [`d318f15`](https://github.com/microsoft/terminal/commit/d318f15cae522efc77161b6831e52397476e16c1) Pid in pipe name, cursor blinking, cleanup - [`e104c9d`](https://github.com/microsoft/terminal/commit/e104c9d20ca779d85f20fa5a8de8ebd2f9fded2f) Add comments, adjust argument values - [`92fff98`](https://github.com/microsoft/terminal/commit/92fff9835f00d36d34b03c2a4dcda3a75615f9c3) Ah format, here we go again - [`571a04f`](https://github.com/microsoft/terminal/commit/571a04f00723da8a816d13ae42c8ab59e327acf5) Add strub Azure handling - [`7d7cb6a`](https://github.com/microsoft/terminal/commit/7d7cb6ae57584a36a5ab366e797d1a3bb801e4e9) Pass process handle, not pid. Cursor bliking - [`b2c632a`](https://github.com/microsoft/terminal/commit/b2c632a2ed6cd98a4fb4558193e90c0a8f7a9a1d) format - [`ed4deac`](https://github.com/microsoft/terminal/commit/ed4deac0aca97de38dcdf9710ad6251d90158156) Connection as event, macros for events - [`7f983ec`](https://github.com/microsoft/terminal/commit/7f983ec8b1e3921ee5dd8bcf3a0168a340659333) Visual state handling, rework connection events ### 📊 Changes **15 files changed** (+496 additions, -187 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalApp/App.cpp` (+1 -1) 📝 `src/cascadia/TerminalApp/Tab.cpp` (+11 -1) 📝 `src/cascadia/TerminalApp/Tab.h` (+2 -0) 📝 `src/cascadia/TerminalConnection/AzureConnection.cpp` (+40 -56) 📝 `src/cascadia/TerminalConnection/AzureConnection.h` (+20 -8) 📝 `src/cascadia/TerminalConnection/ConhostConnection.cpp` (+186 -45) 📝 `src/cascadia/TerminalConnection/ConhostConnection.h` (+29 -8) 📝 `src/cascadia/TerminalConnection/EchoConnection.cpp` (+25 -21) 📝 `src/cascadia/TerminalConnection/EchoConnection.h` (+17 -5) 📝 `src/cascadia/TerminalConnection/ITerminalConnection.idl` (+24 -2) 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+66 -27) 📝 `src/cascadia/TerminalControl/TermControl.h` (+3 -3) 📝 `src/cascadia/TerminalControl/TermControl.idl` (+1 -0) 📝 `src/inc/conpty-universal.h` (+15 -0) 📝 `src/server/Entrypoints.cpp` (+56 -10) </details> ### 📄 Description <!-- 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` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:05:27 +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#24808