Fix env variable caching and add testing arch for environment variable functionality#1044
Closed
eleanorjboyd wants to merge 9 commits intomicrosoft:mainfrom
Closed
Fix env variable caching and add testing arch for environment variable functionality#1044eleanorjboyd wants to merge 9 commits intomicrosoft:mainfrom
eleanorjboyd wants to merge 9 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes environment variable caching issues (#936) by introducing proper tracking of injected environment variables per workspace. The implementation ensures that variables removed or commented out in .env files are properly cleaned up from the terminal environment, and that only tracked variables managed by this injector are removed (preserving variables set by other managers like BASH_ENV).
Key changes:
- Added
trackedEnvVarsMap to track which environment variables are set per workspace - Refactored injection logic to compare previous and current state, deleting variables that are no longer present
- Updated disposal logic to only clean up tracked variables instead of clearing all environment variables
- Comprehensive test suite with both unit tests and integration tests using fixture files
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/features/terminal/terminalEnvVarInjector.ts | Added tracking mechanism for environment variables per workspace, refactored injection and cleanup logic to handle variable removal, and improved dispose method to preserve non-tracked variables |
| src/test/features/terminalEnvVarInjectorBasic.unit.test.ts | Comprehensive unit tests for core functionality including variable addition, updates, deletion, and tracking using test interface pattern for private method access |
| src/test/features/terminalEnvVarInjector.test.ts | Integration tests using real file fixtures to verify complete workflows including file modifications, deletions, configuration changes, and multi-workspace scenarios |
| src/test/fixtures/terminalEnvVarInjector/*.env | Test fixture files covering various scenarios: basic variables, empty files, commented variables, custom paths, unset values, and multi-workspace setups |
| .github/instructions/testing-workflow.instructions.md | Added learnings about fixture-based testing, private access patterns, path handling consistency, and VS Code file watcher limitations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Member
Author
|
closing in favor of work @anthonykim1 will do for envVar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #936