Add setting to enable environment variable injection with simplified configuration notifications#696
Add setting to enable environment variable injection with simplified configuration notifications#696Copilot wants to merge 5 commits into
Conversation
|
@eleanorjboyd 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
…t variable injection Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
|
@copilot switch the setting name to |
…n for envFile usage Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
Changed the setting name to |
|
no i don't want "// Check if python.envFile is set but useEnvFile is false (default) and show notification" instead I want you to only show a notification IF that setting is updated. SO listen so a setting change and then show it otherwise it will be too noisy |
eleanorjboyd
left a comment
There was a problem hiding this comment.
@copilot add an event to listen for a change in the useEnvFile or the python.envFile file value. If either is changed from unset -> set or from false -> true please show a notification to make sure the user has both settings enabled correctly for the expected behavior.
we might assume that a user would change python.envFile and not realize useEnvFile exists which would be frustrating if setting python.envFile doesn't work. this is an example scenario I am trying to avoid
|
|
||
| // Show information message to user | ||
| showInformationMessage( | ||
| 'The python.envFile setting is configured but will not take effect in terminals. Enable the "python.terminal.useEnvFile" setting to use environment variables from .env files in terminals.', |
There was a problem hiding this comment.
@copilot do not show a notification here- I only want to notify the user if the change the value of the python.envFile NOT on extension start
There was a problem hiding this comment.
Removed the immediate notification from the injection method. Notifications are now only shown when settings are actively changed via configuration change listeners, not on extension startup. Commit da4a6a8
|
|
||
| if (!useEnvFile) { | ||
| traceVerbose( | ||
| `TerminalEnvVarInjector: Environment variable injection disabled for workspace: ${workspaceUri.fsPath}`, |
There was a problem hiding this comment.
Switch this to only inject if useEnvFile is true- the turn to get out of injecting is a weird way to do this
There was a problem hiding this comment.
Restructured the injection logic to use positive conditional injection - environment variables are now only injected when useEnvFile is true, instead of the early return pattern. This makes the logic clearer and more straightforward. Commit da4a6a8
| }, | ||
| "python.terminal.useEnvFile": { | ||
| "type": "boolean", | ||
| "description": "Controls whether environment variables from .env files and python.envFile setting are injected into terminals", |
There was a problem hiding this comment.
use l10n for translations for descriptions and sentences
There was a problem hiding this comment.
Added l10n support for the setting description. Updated package.json to use %python-envs.terminal.useEnvFile.description% and added the corresponding translation key to package.nls.json. Commit da4a6a8
…env settings Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
Implemented configuration change listeners instead of immediate notifications. The system now only shows notifications when settings are actively changed (unset->set or false->true) rather than on every extension start. Commit da4a6a8
Added event listeners for both |
| private async initialize(): Promise<void> { | ||
| traceVerbose('TerminalEnvVarInjector: Initializing environment variable injection'); | ||
|
|
||
| // Initialize previous settings state for all workspaces |
There was a problem hiding this comment.
@copilot
no this is now too complicated. lets simplify it to just be:
if user updates python.envFile and they don't have python.useEnvFile set to true, show a notification.
There was a problem hiding this comment.
Simplified the notification logic as requested. Now only shows a notification when user updates python.envFile and they don't have python.useEnvFile set to true. Removed the complex logic that tracked multiple settings and scenarios. Commit: 8ac5db2
…ut useEnvFile is false Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
This PR adds a new setting
python.terminal.useEnvFilethat controls whether environment variables from.envfiles and thepython.envFilesetting are injected into VS Code terminals, with a streamlined notification system to guide users when configuration is needed.Changes
New Setting:
python.terminal.useEnvFilebooleanfalse(injection disabled by default)resource(workspace-specific configuration)Behavior
When
false(default):.envfiles are not injected into terminalsTerminalEnvVarInjectorlogs that injection is disabled and skips processingWhen
true:.envfiles and custompython.envFilepathsSimplified Configuration Notifications:
python.envFilebutpython.terminal.useEnvFileremainsfalseuseEnvFilesetting is required forpython.envFileto take effect in terminalspython.terminal.useEnvFilesettingImplementation Details
The implementation uses a streamlined approach:
python.envFilesetting changes to minimize complexitypython.envFileis updated andpython.terminal.useEnvFileis falsePerformance Benefits:
useEnvFileis falseDeveloper Experience:
python.envFilebut don't realizeuseEnvFileneeds to be enabledTesting
package.jsonwith localization supportFixes #695.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.