[PR #897] [MERGED] set identifying environment variable for new connections #24375

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/897
Author: @binarycrusader
Created: 5/19/2019
Status: ✅ Merged
Merged: 5/22/2019
Merged by: @adiviness

Base: master ← Head: fw-sessionid


📝 Commits (5)

  • f1e4d0e set identifying environment variable for new connections
  • 6b8e777 * use winrt::guid type for connection guid
  • 68e2f50 - poke guid through ITerminalConnection
  • 3be2169 - simplify environment variable extraction in UpdateEnvironmentMapW
  • ed33510 - use Utils::CreateGuid instead of CoCreateGuid in ConHostConnection()

📊 Changes

7 files changed (+276 additions, -54 deletions)

View changed files

📝 src/cascadia/TerminalConnection/ConhostConnection.cpp (+45 -26)
📝 src/cascadia/TerminalConnection/ConhostConnection.h (+17 -15)
📝 src/cascadia/TerminalConnection/ConhostConnection.idl (+3 -1)
📝 src/cascadia/TerminalConnection/TerminalConnection.vcxproj (+12 -0)
📝 src/cascadia/TerminalConnection/pch.h (+6 -0)
📝 src/cascadia/TerminalControl/TermControl.cpp (+2 -2)
📝 src/inc/conpty-universal.h (+191 -10)

📄 Description

Summary of the Pull Request

Set a WT_SESSION environment variable to a unique guid on every new connection to allow shell consumers to detect Windows Terminal and uniquely identify the session.

References

Unknown.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Set a new 'WT_SESSION' environment variable when creating new terminal connections to allow shells to detect a unique Windows Terminal session. The value of the variable is a stringified GUID as returned by
CoCreateGuid.

How verified:

  • "razzle" & vs debug build
  • runut
  • opencon
  • testcon
  • manual inspection

Uncertain about what tests to add and where; all of the existing ones passed.

I did some basic research to try to ensure that "WT_SESSION" is a "unique", non-conflicting environment variable and so shouldn't cause any problems with any existing programs. I'm certainly open to suggestions about the name though.


🔄 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/897 **Author:** [@binarycrusader](https://github.com/binarycrusader) **Created:** 5/19/2019 **Status:** ✅ Merged **Merged:** 5/22/2019 **Merged by:** [@adiviness](https://github.com/adiviness) **Base:** `master` ← **Head:** `fw-sessionid` --- ### 📝 Commits (5) - [`f1e4d0e`](https://github.com/microsoft/terminal/commit/f1e4d0e36af7fa099e80f29adbb5288593cfc1dc) set identifying environment variable for new connections - [`6b8e777`](https://github.com/microsoft/terminal/commit/6b8e7774394b4dbf899b7ed6884478e816caa088) * use winrt::guid type for connection guid - [`68e2f50`](https://github.com/microsoft/terminal/commit/68e2f50ecb2a4494ae35ba07935bd1c92fbc7635) - poke guid through ITerminalConnection - [`3be2169`](https://github.com/microsoft/terminal/commit/3be2169a3079b8482272a2cd4ae3ad210d85c20f) - simplify environment variable extraction in UpdateEnvironmentMapW - [`ed33510`](https://github.com/microsoft/terminal/commit/ed335105c31b61a73a1f9434bd7d5b7baacd688b) - use Utils::CreateGuid instead of CoCreateGuid in ConHostConnection() ### 📊 Changes **7 files changed** (+276 additions, -54 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalConnection/ConhostConnection.cpp` (+45 -26) 📝 `src/cascadia/TerminalConnection/ConhostConnection.h` (+17 -15) 📝 `src/cascadia/TerminalConnection/ConhostConnection.idl` (+3 -1) 📝 `src/cascadia/TerminalConnection/TerminalConnection.vcxproj` (+12 -0) 📝 `src/cascadia/TerminalConnection/pch.h` (+6 -0) 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+2 -2) 📝 `src/inc/conpty-universal.h` (+191 -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 Set a WT_SESSION environment variable to a unique guid on every new connection to allow shell consumers to detect Windows Terminal and uniquely identify the session. <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References Unknown. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [X] Closes #840 * [X] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [x] Tests added/passed * [X] 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: #840 <!-- 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 Set a new 'WT_SESSION' environment variable when creating new terminal connections to allow shells to detect a unique Windows Terminal session. The value of the variable is a stringified GUID as returned by CoCreateGuid. How verified: - "razzle" & vs debug build - runut - opencon - testcon - manual inspection Uncertain about what tests to add and where; all of the existing ones passed. I did some basic research to try to ensure that "WT_SESSION" is a "unique", non-conflicting environment variable and so shouldn't cause any problems with any existing programs. I'm certainly open to suggestions about the name though. --- <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:02:53 +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#24375