[PR #19167] Fix WSLENV environment variable duplication in ConptyConnection #31730

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

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

State: closed
Merged: Yes


Summary

This PR fixes issue #7130 where WT_SESSION and WT_PROFILE_ID environment variables were being duplicated in the WSLENV environment variable when multiple terminal sessions were created.

References and Relevant Issues

Closes #7130

Detailed Description

The previous implementation always appended WT_SESSION:WT_PROFILE_ID: to WSLENV without checking if these variables already existed, causing duplication.

Changes Made:

  • Parse existing WSLENV content to avoid duplicates
  • Only add WT_SESSION and WT_PROFILE_ID if not already present
  • Preserve existing environment variable flags
  • Maintain backward compatibility

Validation Steps Performed

  • Code compiles successfully with dotnet build
  • No build warnings or errors introduced
  • Logic verified through code review
  • Maintains existing functionality while preventing duplication

PR Checklist

**Original Pull Request:** https://github.com/microsoft/terminal/pull/19167 **State:** closed **Merged:** Yes --- ## Summary This PR fixes issue #7130 where WT_SESSION and WT_PROFILE_ID environment variables were being duplicated in the WSLENV environment variable when multiple terminal sessions were created. ## References and Relevant Issues Closes #7130 ## Detailed Description The previous implementation always appended WT_SESSION:WT_PROFILE_ID: to WSLENV without checking if these variables already existed, causing duplication. ### Changes Made: - Parse existing WSLENV content to avoid duplicates - Only add WT_SESSION and WT_PROFILE_ID if not already present - Preserve existing environment variable flags - Maintain backward compatibility ## Validation Steps Performed - [x] Code compiles successfully with dotnet build - [x] No build warnings or errors introduced - [x] Logic verified through code review - [x] Maintains existing functionality while preventing duplication ## PR Checklist - [x] Closes #7130 - [x] Tests added/passed (logic verified) - [ ] Documentation updated (not applicable) - [ ] Schema updated (not applicable)
claunia added the pull-request label 2026-01-31 09:49:10 +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#31730